Search in sources :

Example 1 with RandomizedRunner

use of com.carrotsearch.randomizedtesting.RandomizedRunner 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 2 with RandomizedRunner

use of com.carrotsearch.randomizedtesting.RandomizedRunner 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 3 with RandomizedRunner

use of com.carrotsearch.randomizedtesting.RandomizedRunner 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 4 with RandomizedRunner

use of com.carrotsearch.randomizedtesting.RandomizedRunner in project randomizedtesting by randomizedtesting.

the class TestBeforeAfterMethodOrder method checkOrderFixedSeed.

@Test
public void checkOrderFixedSeed() throws Exception {
    new JUnitCore().run(new RandomizedRunner(SubSubFixedSeed.class));
    ArrayList<String> order = new ArrayList<String>(callOrder);
    callOrder.clear();
    new JUnitCore().run(new RandomizedRunner(SubSubFixedSeed.class));
    assertEquals(order, callOrder);
}
Also used : RandomizedRunner(com.carrotsearch.randomizedtesting.RandomizedRunner) JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with RandomizedRunner

use of com.carrotsearch.randomizedtesting.RandomizedRunner in project randomizedtesting by randomizedtesting.

the class TestBeforeAfterMethodOrder method checkOrder.

@Test
public void checkOrder() throws Exception {
    // Normal JUnit.
    checkTestsOutput(1, 0, 0, 0, SubSub.class);
    ArrayList<String> junitOrder = new ArrayList<String>(callOrder);
    callOrder.clear();
    new JUnitCore().run(new RandomizedRunner(SubSub.class));
    if (!callOrder.equals(junitOrder)) {
        final int i = junitOrder.size();
        final int j = callOrder.size();
        System.out.println(String.format(Locale.ROOT, "%-30s | %-30s", "JUnit4", "RR"));
        for (int k = 0; k < Math.max(i, j); k++) {
            System.out.println(String.format(Locale.ROOT, "%-30s | %-30s", k < i ? junitOrder.get(k) : "--", k < j ? callOrder.get(k) : "--"));
        }
        Assert.fail("JUnit4 and RandomizedRunner differed.");
    }
}
Also used : RandomizedRunner(com.carrotsearch.randomizedtesting.RandomizedRunner) JUnitCore(org.junit.runner.JUnitCore) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

RandomizedRunner (com.carrotsearch.randomizedtesting.RandomizedRunner)7 JUnitCore (org.junit.runner.JUnitCore)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)3