Search in sources :

Example 66 with Test

use of junit.framework.Test in project junit4 by junit-team.

the class SuiteTest method testNoTestCases.

public void testNoTestCases() {
    Test t = new TestSuite(NoTestCases.class);
    t.run(fResult);
    // warning test
    assertTrue(fResult.runCount() == 1);
    assertTrue(fResult.failureCount() == 1);
    assertTrue(!fResult.wasSuccessful());
}
Also used : TestSuite(junit.framework.TestSuite) Test(junit.framework.Test)

Example 67 with Test

use of junit.framework.Test in project junit4 by junit-team.

the class ActiveTestTest method testActiveRepeatedTest0.

public void testActiveRepeatedTest0() {
    Test test = new RepeatedTest(createActiveTestSuite(), 0);
    TestResult result = new TestResult();
    test.run(result);
    assertEquals(0, result.runCount());
    assertEquals(0, result.failureCount());
    assertEquals(0, result.errorCount());
}
Also used : Test(junit.framework.Test) RepeatedTest(junit.extensions.RepeatedTest) RepeatedTest(junit.extensions.RepeatedTest) TestResult(junit.framework.TestResult)

Example 68 with Test

use of junit.framework.Test in project junit4 by junit-team.

the class RepeatedTestTest method testRepeatedOnce.

public void testRepeatedOnce() {
    Test test = new RepeatedTest(fSuite, 1);
    assertEquals(2, test.countTestCases());
    TestResult result = new TestResult();
    test.run(result);
    assertEquals(2, result.runCount());
}
Also used : Test(junit.framework.Test) RepeatedTest(junit.extensions.RepeatedTest) RepeatedTest(junit.extensions.RepeatedTest) TestResult(junit.framework.TestResult)

Example 69 with Test

use of junit.framework.Test in project caffeine by ben-manes.

the class JSR166TestCase method addNamedTestClasses.

public static void addNamedTestClasses(TestSuite suite, String... testClassNames) {
    for (String testClassName : testClassNames) {
        try {
            Class<?> testClass = Class.forName(testClassName);
            Method m = testClass.getDeclaredMethod("suite", new Class<?>[0]);
            suite.addTest(newTestSuite((Test) m.invoke(null)));
        } catch (Exception e) {
            throw new Error("Missing test class", e);
        }
    }
}
Also used : Test(junit.framework.Test) AssertionFailedError(junit.framework.AssertionFailedError) Method(java.lang.reflect.Method) TimeoutException(java.util.concurrent.TimeoutException) NoSuchElementException(java.util.NoSuchElementException)

Example 70 with Test

use of junit.framework.Test in project caffeine by ben-manes.

the class JSR166TestCase method main.

/**
     * Runs all JSR166 unit tests using junit.textui.TestRunner.
     * Optional command line arg provides the number of iterations to
     * repeat running the tests.
     */
public static void main(String[] args) {
    if (useSecurityManager) {
        System.err.println("Setting a permissive security manager");
        Policy.setPolicy(permissivePolicy());
        System.setSecurityManager(new SecurityManager());
    }
    int iters = (args.length == 0) ? 1 : Integer.parseInt(args[0]);
    Test s = suite();
    for (int i = 0; i < iters; ++i) {
        junit.textui.TestRunner.run(s);
        System.gc();
        System.runFinalization();
    }
    System.exit(0);
}
Also used : Test(junit.framework.Test)

Aggregations

Test (junit.framework.Test)114 TestSuite (junit.framework.TestSuite)45 TestCase (junit.framework.TestCase)22 ArrayList (java.util.ArrayList)13 InvocationTargetException (java.lang.reflect.InvocationTargetException)12 Method (java.lang.reflect.Method)12 AssertionFailedError (junit.framework.AssertionFailedError)12 TestListener (junit.framework.TestListener)11 TestResult (junit.framework.TestResult)11 TestDescriptor (android.test.suitebuilder.ListTestCaseNames.TestDescriptor)10 SmallTest (android.test.suitebuilder.annotation.SmallTest)10 Enumeration (java.util.Enumeration)10 RepeatedTest (junit.extensions.RepeatedTest)7 AndroidTestRunner (android.test.AndroidTestRunner)5 Field (java.lang.reflect.Field)5 List (java.util.List)5 IOException (java.io.IOException)3 PrintWriter (java.io.PrintWriter)2 JUnit4TestAdapter (junit.framework.JUnit4TestAdapter)2 GridAbstractTest (org.apache.ignite.testframework.junits.GridAbstractTest)2