Search in sources :

Example 6 with JUnitCore

use of org.junit.runner.JUnitCore in project randomizedtesting by randomizedtesting.

the class TestAnnotationInheritance method assertSameExecution.

private void assertSameExecution(Class<?> clazz) throws Exception {
    order.clear();
    runTests(clazz);
    List<String> order1 = new ArrayList<>(order);
    order.clear();
    new JUnitCore().run(Request.runner(new RandomizedRunner(clazz)));
    List<String> order2 = new ArrayList<>(order);
    order.clear();
    String msg = "# JUnit order:\n" + order1 + "\n" + "# RR order:\n" + order2;
    Assertions.assertThat(order2).as(msg).isEqualTo(order1);
}
Also used : RandomizedRunner(com.carrotsearch.randomizedtesting.RandomizedRunner) JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList)

Example 7 with JUnitCore

use of org.junit.runner.JUnitCore in project randomizedtesting by randomizedtesting.

the class TestClassRules method assertSameExecution.

private void assertSameExecution(Class<?> clazz) throws Exception {
    order.clear();
    runTests(clazz);
    List<String> order1 = new ArrayList<>(order);
    order.clear();
    new JUnitCore().run(Request.runner(new RandomizedRunner(clazz)));
    List<String> order2 = new ArrayList<>(order);
    order.clear();
    Assert.assertEquals(order1, order2);
}
Also used : RandomizedRunner(com.carrotsearch.randomizedtesting.RandomizedRunner) JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList)

Example 8 with JUnitCore

use of org.junit.runner.JUnitCore in project randomizedtesting by randomizedtesting.

the class PrivateHooksPropagation method assertSameExecution.

private void assertSameExecution(Class<?> clazz) throws Exception {
    new JUnitCore().run(Request.runner(new RandomizedRunner(clazz)));
    List<String> order1 = new ArrayList<>(order);
    order.clear();
    String msg = "# RR order:\n" + order1;
    Assertions.assertThat(order1).as(msg).containsOnly("super.beforeclass1", "sub.beforeclass1", "sub.beforeclass2", "super.before1", "sub.before1", "sub.before2", "super.testMethod1");
}
Also used : RandomizedRunner(com.carrotsearch.randomizedtesting.RandomizedRunner) JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList)

Example 9 with JUnitCore

use of org.junit.runner.JUnitCore in project randomizedtesting by randomizedtesting.

the class TestCustomMethodProvider method testJUnit4Valid.

@Test
public void testJUnit4Valid() throws InitializationError {
    Class<?>[] valid = { T1.class, RT1.class };
    for (Class<?> cl : valid) {
        Result r = new JUnitCore().run(new RandomizedRunner(cl));
        Assert.assertEquals(0, r.getFailureCount());
        Assert.assertEquals(1, r.getRunCount());
    }
}
Also used : JUnitCore(org.junit.runner.JUnitCore) Result(org.junit.runner.Result) Test(org.junit.Test)

Example 10 with JUnitCore

use of org.junit.runner.JUnitCore in project randomizedtesting by randomizedtesting.

the class TestJUnit3MethodProvider method testJUnit3Invalid.

@Test
public void testJUnit3Invalid() {
    Class<?>[] invalid = { T2.class, T3.class, T4.class, ST1.class, ST2.class, ST3.class, ST4.class, AT1.class };
    for (Class<?> cl : invalid) {
        try {
            new JUnitCore().run(new RandomizedRunner(cl));
            Assert.fail("Expected to fail for: " + cl);
        } catch (InitializationError e) {
        // expected.
        }
    }
}
Also used : JUnitCore(org.junit.runner.JUnitCore) InitializationError(org.junit.runners.model.InitializationError) Test(org.junit.Test)

Aggregations

JUnitCore (org.junit.runner.JUnitCore)173 Result (org.junit.runner.Result)104 Test (org.junit.Test)88 Request (org.junit.runner.Request)33 Failure (org.junit.runner.notification.Failure)24 PrintableResult.testResult (org.junit.experimental.results.PrintableResult.testResult)22 RunListener (org.junit.runner.notification.RunListener)17 Description (org.junit.runner.Description)16 ArrayList (java.util.ArrayList)14 TestResult (junit.framework.TestResult)14 TextListener (org.junit.internal.TextListener)12 Runner (org.junit.runner.Runner)9 RandomizedRunner (com.carrotsearch.randomizedtesting.RandomizedRunner)7 TestSuiteModel (com.google.testing.junit.runner.model.TestSuiteModel)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 OutputStream (java.io.OutputStream)5 CategoryFilter (org.junit.experimental.categories.Categories.CategoryFilter)5 File (java.io.File)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 InOrder (org.mockito.InOrder)4