use of com.google.testing.junit.runner.sharding.testing.FakeShardingFilters in project bazel by bazelbuild.
the class JUnit4RunnerTest method testRunPassesWhenNoTestsOnCurrentShardWithFiltering.
@Test
public void testRunPassesWhenNoTestsOnCurrentShardWithFiltering() {
config = createConfig("testThatAlwaysFails");
shardingEnvironment = mock(ShardingEnvironment.class);
shardingFilters = new FakeShardingFilters(Description.createTestDescription(SamplePassingTest.class, "testThatAlwaysPasses"));
when(shardingEnvironment.isShardingEnabled()).thenReturn(true);
JUnit4Runner runner = createRunner(SampleSuite.class);
Result result = runner.run();
verify(shardingEnvironment).touchShardFile();
assertEquals(0, result.getRunCount());
assertEquals(0, result.getFailureCount());
assertEquals(0, result.getIgnoreCount());
}
use of com.google.testing.junit.runner.sharding.testing.FakeShardingFilters in project bazel by bazelbuild.
the class JUnit4RunnerTest method testFilteringAndShardingTogetherIsSupported.
@Test
public void testFilteringAndShardingTogetherIsSupported() {
config = createConfig("testThatAlways(Passes|Fails)");
shardingEnvironment = mock(ShardingEnvironment.class);
shardingFilters = new FakeShardingFilters(Description.createTestDescription(SamplePassingTest.class, "testThatAlwaysPasses"), Description.createTestDescription(SampleFailingTest.class, "testThatAlwaysFails"));
when(shardingEnvironment.isShardingEnabled()).thenReturn(true);
JUnit4Runner runner = createRunner(SampleSuite.class);
Result result = runner.run();
verify(shardingEnvironment).touchShardFile();
assertEquals(2, result.getRunCount());
assertEquals(1, result.getFailureCount());
assertEquals(0, result.getIgnoreCount());
assertEquals(Description.createTestDescription(SampleFailingTest.class, "testThatAlwaysFails"), result.getFailures().get(0).getDescription());
}
use of com.google.testing.junit.runner.sharding.testing.FakeShardingFilters in project bazel by bazelbuild.
the class JUnit4RunnerTest method testShardingIsSupported.
@Test
public void testShardingIsSupported() {
config = createConfig();
shardingEnvironment = mock(ShardingEnvironment.class);
shardingFilters = new FakeShardingFilters(Description.createTestDescription(SamplePassingTest.class, "testThatAlwaysPasses"), Description.createTestDescription(SampleFailingTest.class, "testThatAlwaysFails"));
when(shardingEnvironment.isShardingEnabled()).thenReturn(true);
JUnit4Runner runner = createRunner(SampleSuite.class);
Result result = runner.run();
verify(shardingEnvironment).touchShardFile();
assertEquals(2, result.getRunCount());
if (result.getFailureCount() > 1) {
fail("Too many failures: " + result.getFailures());
}
assertEquals(1, result.getFailureCount());
assertEquals(0, result.getIgnoreCount());
assertEquals(2, runner.getModel().getNumTestCases());
}
Aggregations