use of com.google.testing.junit.runner.sharding.ShardingFilters in project bazel by bazelbuild.
the class JUnit4TestModelBuilderTest method testTouchesShardFileWhenShardingEnabled.
@Test
public void testTouchesShardFileWhenShardingEnabled() {
Class<?> testClass = SampleTestCaseWithTwoTests.class;
Request request = Request.classWithoutSuiteMethod(testClass);
ShardingEnvironment mockShardingEnvironment = mock(ShardingEnvironment.class);
ShardingFilters shardingFilters = new ShardingFilters(mockShardingEnvironment, DEFAULT_SHARDING_STRATEGY);
JUnit4TestModelBuilder modelBuilder = builder(request, testClass.getCanonicalName(), mockShardingEnvironment, shardingFilters, xmlResultWriter);
when(mockShardingEnvironment.isShardingEnabled()).thenReturn(true);
when(mockShardingEnvironment.getTotalShards()).thenReturn(2);
modelBuilder.get();
verify(mockShardingEnvironment).touchShardFile();
}
use of com.google.testing.junit.runner.sharding.ShardingFilters in project bazel by bazelbuild.
the class JUnit4RunnerTest method testRunFailsWhenNoTestsOnCurrentShardWithoutFiltering.
@Test
public void testRunFailsWhenNoTestsOnCurrentShardWithoutFiltering() {
config = createConfig();
shardingEnvironment = mock(ShardingEnvironment.class);
shardingFilters = mock(ShardingFilters.class);
when(shardingEnvironment.isShardingEnabled()).thenReturn(true);
when(shardingFilters.createShardingFilter(anyListOf(Description.class))).thenReturn(new NoneShallPassFilter());
JUnit4Runner runner = createRunner(SampleSuite.class);
Result result = runner.run();
assertEquals(1, result.getRunCount());
assertEquals(1, result.getFailureCount());
assertEquals(0, result.getIgnoreCount());
assertTrue(result.getFailures().get(0).getMessage().contains("No tests found"));
verify(shardingEnvironment).touchShardFile();
verify(shardingFilters).createShardingFilter(anyListOf(Description.class));
}
use of com.google.testing.junit.runner.sharding.ShardingFilters in project bazel by bazelbuild.
the class JUnit4TestModelBuilderTest method testDoesNotTouchShardFileWhenShardingDisabled.
@Test
public void testDoesNotTouchShardFileWhenShardingDisabled() {
Class<?> testClass = SampleTestCaseWithTwoTests.class;
Request request = Request.classWithoutSuiteMethod(testClass);
ShardingEnvironment mockShardingEnvironment = mock(ShardingEnvironment.class);
ShardingFilters shardingFilters = new ShardingFilters(mockShardingEnvironment, DEFAULT_SHARDING_STRATEGY);
JUnit4TestModelBuilder modelBuilder = builder(request, testClass.getCanonicalName(), mockShardingEnvironment, shardingFilters, xmlResultWriter);
when(mockShardingEnvironment.isShardingEnabled()).thenReturn(false);
modelBuilder.get();
verify(mockShardingEnvironment, never()).touchShardFile();
}
Aggregations