use of com.teamscale.report.testwise.model.TestwiseCoverageReport in project teamscale-jacoco-agent by cqse.
the class CoverageToTeamscaleStrategy method createTestwiseCoverageReport.
/**
* Creates a testwise coverage report from the coverage collected in {@link #testExecFile} and the test execution
* information in {@link #testExecutions}.
*/
private String createTestwiseCoverageReport() throws IOException, CoverageGenerationException {
List<String> executionUniformPaths = testExecutions.stream().map(execution -> {
if (execution == null) {
return null;
} else {
return execution.getUniformPath();
}
}).collect(toList());
logger.debug("Creating testwise coverage form available tests `{}`, test executions `{}` and exec file", availableTests.stream().map(test -> test.uniformPath).collect(toList()), executionUniformPaths);
TestwiseCoverage testwiseCoverage = reportGenerator.convert(testExecFile);
logger.debug("Created testwise coverage report (containing coverage for tests `{}`)", testwiseCoverage.getTests().stream().map(TestCoverageBuilder::getUniformPath).collect(toList()));
TestwiseCoverageReport report = TestwiseCoverageReportBuilder.createFrom(availableTests, testwiseCoverage.getTests(), testExecutions);
testExecFile.delete();
testExecFile = null;
availableTests.clear();
testExecutions.clear();
return testwiseCoverageReportJsonAdapter.toJson(report);
}
use of com.teamscale.report.testwise.model.TestwiseCoverageReport in project teamscale-jacoco-agent by cqse.
the class TiaClientSystemTest method systemTest.
@Test
public void systemTest() throws Exception {
TeamscaleMockServer teamscaleMockServer = new TeamscaleMockServer(FAKE_TEAMSCALE_PORT, "testFoo", "testBar");
CustomTestFramework customTestFramework = new CustomTestFramework(AGENT_PORT);
customTestFramework.runTestsWithTia();
assertThat(teamscaleMockServer.uploadedReports).hasSize(1);
TestwiseCoverageReport report = teamscaleMockServer.parseUploadedTestwiseCoverageReport(0);
assertThat(report.tests).hasSize(2);
assertAll(() -> {
assertThat(report.tests).extracting(test -> test.uniformPath).containsExactlyInAnyOrder("testBar", "testFoo");
assertThat(report.tests).extracting(test -> test.result).containsExactlyInAnyOrder(ETestExecutionResult.FAILURE, ETestExecutionResult.PASSED);
assertThat(report.tests).extracting(TiaClientSystemTest::getCoverageString).containsExactlyInAnyOrder("SystemUnderTest.java:4,13", "SystemUnderTest.java:4,8");
});
}
use of com.teamscale.report.testwise.model.TestwiseCoverageReport in project teamscale-jacoco-agent by cqse.
the class TestwiseCoverageReportBuilder method build.
private TestwiseCoverageReport build() {
TestwiseCoverageReport report = new TestwiseCoverageReport();
List<TestInfoBuilder> testInfoBuilders = new ArrayList<>(tests.values());
testInfoBuilders.sort(Comparator.comparing(TestInfoBuilder::getUniformPath));
for (TestInfoBuilder testInfoBuilder : testInfoBuilders) {
TestInfo testInfo = testInfoBuilder.build();
if (testInfo == null) {
System.err.println("No coverage for test '" + testInfoBuilder.getUniformPath() + "'");
continue;
}
report.tests.add(testInfo);
}
return report;
}
use of com.teamscale.report.testwise.model.TestwiseCoverageReport in project teamscale-jacoco-agent by cqse.
the class JUnitRunListenerSystemTest method testJUnit4RunListener.
/**
* Tests the JUnit 4 {@link org.junit.runner.notification.RunListener}.
*/
@Test
public void testJUnit4RunListener() throws Exception {
runMavenTests("junit4-maven-project");
assertThat(teamscaleMockServer.uploadedReports).hasSize(1);
TestwiseCoverageReport report = teamscaleMockServer.parseUploadedTestwiseCoverageReport(0);
assertThat(report.tests).hasSize(1);
assertAll(() -> {
assertThat(report.tests).extracting(test -> test.uniformPath).containsExactlyInAnyOrder("JUnit4Test/testAdd");
assertThat(report.tests).extracting(test -> test.result).containsExactlyInAnyOrder(ETestExecutionResult.PASSED);
assertThat(report.tests).extracting(JUnitRunListenerSystemTest::getCoverageString).containsExactly("SystemUnderTest.java:3,6");
});
}
use of com.teamscale.report.testwise.model.TestwiseCoverageReport in project teamscale-jacoco-agent by cqse.
the class JUnitRunListenerSystemTest method testJUnit5TestExecutionListener.
/**
* Tests the JUnit 5 {@link org.junit.platform.launcher.TestExecutionListener}.
*/
@Test
public void testJUnit5TestExecutionListener() throws Exception {
runMavenTests("junit5-maven-project");
assertThat(teamscaleMockServer.uploadedReports).hasSize(1);
TestwiseCoverageReport report = teamscaleMockServer.parseUploadedTestwiseCoverageReport(0);
assertThat(report.tests).hasSize(2);
assertAll(() -> {
assertThat(report.tests).extracting(test -> test.uniformPath).containsExactlyInAnyOrder("JUnit4ExecutedWithJUnit5Test/testAdd()", "JUnit5Test/testAdd()");
assertThat(report.tests).extracting(test -> test.result).containsExactlyInAnyOrder(ETestExecutionResult.PASSED, ETestExecutionResult.PASSED);
assertThat(report.tests).extracting(JUnitRunListenerSystemTest::getCoverageString).containsExactly("SystemUnderTest.java:3,6", "SystemUnderTest.java:3,6");
});
}
Aggregations