Search in sources :

Example 1 with TextListener

use of org.junit.internal.TextListener in project junit4 by junit-team.

the class JUnitCore method runMain.

/**
     * @param system
     * @param args from main()
     */
Result runMain(JUnitSystem system, String... args) {
    system.out().println("JUnit version " + Version.id());
    JUnitCommandLineParseResult jUnitCommandLineParseResult = JUnitCommandLineParseResult.parse(args);
    RunListener listener = new TextListener(system);
    addListener(listener);
    return run(jUnitCommandLineParseResult.createRequest(defaultComputer()));
}
Also used : TextListener(org.junit.internal.TextListener) RunListener(org.junit.runner.notification.RunListener)

Example 2 with TextListener

use of org.junit.internal.TextListener in project mockito by mockito.

the class MockInjectionUsingConstructorTest method constructor_is_called_for_each_test_in_test_class.

@Test
public void constructor_is_called_for_each_test_in_test_class() throws Exception {
    // given
    junit_test_with_3_tests_methods.constructor_instantiation = 0;
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));
    // when
    jUnitCore.run(junit_test_with_3_tests_methods.class);
    // then
    assertThat(junit_test_with_3_tests_methods.constructor_instantiation).isEqualTo(3);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) TextListener(org.junit.internal.TextListener) Test(org.junit.Test)

Example 3 with TextListener

use of org.junit.internal.TextListener in project robovm by robovm.

the class RoboVMAllTests method main.

public static void main(String[] args) throws Exception {
    System.out.println("JUnit version " + Version.id());
    JUnitCore core = new JUnitCore();
    core.addListener(new TextListener(System.out) {

        @Override
        public void testStarted(Description description) {
            System.out.print(description + " ... ");
        }

        @Override
        public void testFinished(Description description) {
            System.out.println();
        }

        @Override
        public void testFailure(Failure failure) {
            System.out.print("FAILED!");
        }

        @Override
        public void testIgnored(Description description) {
            System.out.println("IGNORED!");
        }
    });
    core.run(suite(Pattern.compile(args.length > 0 ? args[0] : ".*"), Pattern.compile(args.length > 1 ? args[1] : " "), false));
}
Also used : Description(org.junit.runner.Description) JUnitCore(org.junit.runner.JUnitCore) TextListener(org.junit.internal.TextListener) Failure(org.junit.runner.notification.Failure)

Example 4 with TextListener

use of org.junit.internal.TextListener in project robovm by robovm.

the class RunAllTests method main.

public static void main(String[] args) {
    List<Class<?>> classes = new ArrayList<>();
    for (Class<?> cls : VM.listClasses(Object.class, ClassLoader.getSystemClassLoader())) {
        if (!cls.getName().startsWith("junit.") && !cls.getName().startsWith("org.junit.")) {
            if (TestCase.class.isAssignableFrom(cls)) {
                classes.add(cls);
                continue;
            }
            for (Method m : cls.getMethods()) {
                if (m.getAnnotation(Test.class) != null) {
                    classes.add(cls);
                    break;
                }
            }
        }
    }
    JUnitCore jc = new JUnitCore();
    jc.addListener(new TextListener(System.out));
    jc.run(classes.toArray(new Class[classes.size()]));
    System.out.flush();
    System.exit(0);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Test(org.junit.Test) ArrayList(java.util.ArrayList) TextListener(org.junit.internal.TextListener) Method(java.lang.reflect.Method)

Example 5 with TextListener

use of org.junit.internal.TextListener in project spring-boot by spring-projects.

the class DelegateTestRunner method run.

public static void run(Class<?>[] testClasses, Result result) {
    JUnitCore jUnitCore = new JUnitCore();
    jUnitCore.addListener(new TextListener(System.out));
    jUnitCore.addListener(result.createListener());
    jUnitCore.run(testClasses);
}
Also used : JUnitCore(org.junit.runner.JUnitCore) TextListener(org.junit.internal.TextListener)

Aggregations

TextListener (org.junit.internal.TextListener)15 JUnitCore (org.junit.runner.JUnitCore)12 Result (org.junit.runner.Result)6 RunListener (org.junit.runner.notification.RunListener)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2 JUnitSystem (org.junit.internal.JUnitSystem)2 RealSystem (org.junit.internal.RealSystem)2 Description (org.junit.runner.Description)2 Request (org.junit.runner.Request)2 Failure (org.junit.runner.notification.Failure)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 Pattern (java.util.regex.Pattern)1