Search in sources :

Example 1 with ParallelComputer

use of org.junit.experimental.ParallelComputer in project tutorials by eugenp.

the class Spring5JUnit5ParallelIntegrationTest method givenTwoTestClasses_whenJUnitRunParallel_thenTheTestsExecutingParallel.

@Test
void givenTwoTestClasses_whenJUnitRunParallel_thenTheTestsExecutingParallel() {
    final Class<?>[] classes = { Example1IntegrationTest.class, Example2IntegrationTest.class };
    JUnitCore.runClasses(new ParallelComputer(true, true), classes);
}
Also used : ParallelComputer(org.junit.experimental.ParallelComputer) Test(org.junit.jupiter.api.Test) Example2IntegrationTest(com.baeldung.Example2IntegrationTest) Example1IntegrationTest(com.baeldung.Example1IntegrationTest)

Example 2 with ParallelComputer

use of org.junit.experimental.ParallelComputer in project azure-iot-sdk-java by Azure.

the class LongHaulIT method runLongHaulTests.

@Test
public void runLongHaulTests() {
    Class<?>[] classes = { LongHaulMessageTests.class };
    JUnitCore.runClasses(new ParallelComputer(true, true), classes);
}
Also used : ParallelComputer(org.junit.experimental.ParallelComputer) AfterClass(org.junit.AfterClass) BeforeClass(org.junit.BeforeClass) Test(org.junit.Test)

Example 3 with ParallelComputer

use of org.junit.experimental.ParallelComputer in project tutorials by eugenp.

the class ParallelIntegrationTest method runTestsInParallel.

@Test
public void runTestsInParallel() {
    final Class<?>[] classes = { Example1IntegrationTest.class, Example2IntegrationTest.class };
    JUnitCore.runClasses(new ParallelComputer(true, true), classes);
}
Also used : ParallelComputer(org.junit.experimental.ParallelComputer) Test(org.junit.Test)

Example 4 with ParallelComputer

use of org.junit.experimental.ParallelComputer in project opennars by opennars.

the class NALTest method runTests.

public static double runTests(Class c) {
    tests.clear();
    scores.clear();
    if (waitForEnterKeyOnStart) {
        System.out.println("When ready, press enter");
        try {
            System.in.read();
        } catch (IOException ex) {
        }
    }
    // Result result = org.junit.runner.JUnitCore.runClasses(NALTest.class);
    Result result = JUnitCore.runClasses(new ParallelComputer(true, true), c);
    for (Failure f : result.getFailures()) {
        String test = f.getMessage().substring(f.getMessage().indexOf("test/nal") + 8, f.getMessage().indexOf(".nal"));
        tests.put(test, false);
    }
    int[] levelSuccess = new int[10];
    int[] levelTotals = new int[10];
    for (Map.Entry<String, Boolean> e : tests.entrySet()) {
        String name = e.getKey();
        int level = 0;
        try {
            level = Integer.parseInt(name.split("\\.")[0]);
        } catch (NumberFormatException ne) {
        }
        levelTotals[level]++;
        if (e.getValue()) {
            levelSuccess[level]++;
        }
    }
    double totalScore = 0;
    for (Double d : scores.values()) totalScore += d;
    if (showReport) {
        int totalSucceeded = 0, total = 0;
        for (int i = 0; i < 9; i++) {
            float rate = (levelTotals[i] > 0) ? ((float) levelSuccess[i]) / levelTotals[i] : 0;
            String prefix = (i > 0) ? ("NAL" + i) : "Other";
            System.out.println(prefix + ": " + (rate * 100.0) + "%  (" + levelSuccess[i] + "/" + levelTotals[i] + ")");
            totalSucceeded += levelSuccess[i];
            total += levelTotals[i];
        }
        System.out.println(totalSucceeded + " / " + total);
        System.out.println("Score: " + totalScore);
    }
    return totalScore;
}
Also used : ParallelComputer(org.junit.experimental.ParallelComputer) IOException(java.io.IOException) Result(org.junit.runner.Result) HashMap(java.util.HashMap) Map(java.util.Map) Failure(org.junit.runner.notification.Failure)

Example 5 with ParallelComputer

use of org.junit.experimental.ParallelComputer in project cucumber-jvm by cucumber.

the class CucumberTest method cucumber_can_run_features_in_parallel.

@Test
void cucumber_can_run_features_in_parallel() throws Exception {
    RunNotifier notifier = new RunNotifier();
    RunListener listener = Mockito.mock(RunListener.class);
    notifier.addListener(listener);
    ParallelComputer computer = new ParallelComputer(true, true);
    Request.classes(computer, ValidEmpty.class).getRunner().run(notifier);
    {
        InOrder order = Mockito.inOrder(listener);
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("Followed by some examples #1(Feature A)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("Followed by some examples #1(Feature A)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("Followed by some examples #2(Feature A)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("Followed by some examples #2(Feature A)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("Followed by some examples #3(Feature A)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("Followed by some examples #3(Feature A)")));
    }
    {
        InOrder order = Mockito.inOrder(listener);
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("A(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("A(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("B(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("B(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("C #1(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("C #1(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("C #2(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("C #2(Feature B)")));
        order.verify(listener).testStarted(argThat(new DescriptionMatcher("C #3(Feature B)")));
        order.verify(listener).testFinished(argThat(new DescriptionMatcher("C #3(Feature B)")));
    }
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) InOrder(org.mockito.InOrder) ParallelComputer(org.junit.experimental.ParallelComputer) RunListener(org.junit.runner.notification.RunListener) Test(org.junit.jupiter.api.Test)

Aggregations

ParallelComputer (org.junit.experimental.ParallelComputer)6 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)2 Example1IntegrationTest (com.baeldung.Example1IntegrationTest)1 Example2IntegrationTest (com.baeldung.Example2IntegrationTest)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AfterClass (org.junit.AfterClass)1 BeforeClass (org.junit.BeforeClass)1 Result (org.junit.runner.Result)1 Failure (org.junit.runner.notification.Failure)1 RunListener (org.junit.runner.notification.RunListener)1 RunNotifier (org.junit.runner.notification.RunNotifier)1 InOrder (org.mockito.InOrder)1