private Function<Integer, TestInfo> timeToTestInfo() { return a -> new TestInfo("foo", "bar", a, Optional.<ClassName> empty(), 0); }
private Function<Integer, TestInfo> timeToTestInfo() { return a -> new TestInfo("foo", "bar", a, Optional.<ClassName> empty(), 0); }
private TestInfo testInfo(final int time, final String target, final int linesCovered) { return new TestInfo("", time + target + linesCovered, time, Optional.ofNullable(ClassName.fromString(target)), linesCovered); }
private Function<String, TestInfo> toTestInfo(final BlockCoverage blockData) { return a -> new TestInfo(null, a, 0, Optional.ofNullable(blockData.getBlock().getLocation().getClassName()), blockData.getBlock().getBlock()); }
private TestInfo createTestInfo(final Description description, final int executionTime, final int linesCovered) { final Optional<ClassName> testee = this.code.findTestee(description .getFirstTestClass()); return new TestInfo(description.getFirstTestClass(), description.getQualifiedName(), executionTime, testee, linesCovered); }
@Test public void shouldReturnTestUnitWhenMatchingTestDetailSupplied() { final List<TestUnit> actual = this.testee.translateTests(Arrays .asList(new TestInfo("foo", "one", 42, Optional.<ClassName> empty(), 0))); assertEquals(1, actual.size()); }
@Test public void shouldReturnNoTestUnitWhenNonMatchingTestDetailSupplied() { assertTrue(this.testee.translateTests( Arrays.asList(new TestInfo("foo", "bar", 42, Optional.<ClassName> empty(), 0))).isEmpty()); }
@Test public void shouldTreatIdenticallyNamesTestsAsEqual() { final TestInfo sameName = new TestInfo("bar", "0name", 1000, Optional.<ClassName> empty(), 0); assertEquals(0, this.testee.compare(this.lhs, sameName)); }
@Test public void shouldStartPreviousKilledMutationsAtAStatusOfNotStartedWhenNeitherClassOrTestHasChanged() { final MutationDetails md = makeMutation("foo"); final String killingTest = "fooTest"; setHistoryForAllMutationsTo(DetectionStatus.KILLED, killingTest); final Collection<TestInfo> tests = Collections.singleton(new TestInfo( "TEST_CLASS", killingTest, 0, Optional.<ClassName> empty(), 0)); when(this.coverage.getTestsForClass(any(ClassName.class))) .thenReturn(tests); when(this.history.hasClassChanged(any(ClassName.class))).thenReturn(false); final MutationResult actual = this.testee .analyse(Collections.singletonList(md)).iterator().next(); assertEquals(DetectionStatus.KILLED, actual.getStatus()); assertEquals(Optional.ofNullable(killingTest), actual.getKillingTest()); }
@Test public void shouldStartPreviousKilledMutationsAtAStatusOfKilledWhenNeitherClassOrTestHasChanged() { final MutationDetails md = makeMutation("foo"); final String killingTest = "fooTest"; setHistoryForAllMutationsTo(DetectionStatus.KILLED, killingTest); final Collection<TestInfo> tests = Collections.singleton(new TestInfo( "TEST_CLASS", killingTest, 0, Optional.<ClassName> empty(), 0)); when(this.coverage.getTestsForClass(any(ClassName.class))) .thenReturn(tests); when(this.history.hasClassChanged(ClassName.fromString("foo"))).thenReturn( false); when(this.history.hasClassChanged(ClassName.fromString("TEST_CLASS"))) .thenReturn(true); final MutationResult actual = this.testee .analyse(Collections.singletonList(md)).iterator().next(); assertEquals(DetectionStatus.NOT_STARTED, actual.getStatus()); }
TestInfo info = new TestInfo(); info.setFields(map); store().put(info);