Search in sources :

Example 1 with ClasspathWildcardIncludeFilter

use of com.teamscale.report.util.ClasspathWildcardIncludeFilter in project teamscale-jacoco-agent by cqse.

the class JaCoCoXmlReportGeneratorTest method testEmptyCoverageFileThrowsException.

@Test
void testEmptyCoverageFileThrowsException() throws IOException {
    String testFolderName = "empty-report-handling";
    long classId = calculateClassId(testFolderName, "TestClass.class");
    assertThatThrownBy(() -> runGenerator(testFolderName, EDuplicateClassFileBehavior.IGNORE, false, new ClasspathWildcardIncludeFilter("some.package.*", null), createDummyDump(classId))).isExactlyInstanceOf(EmptyReportException.class);
}
Also used : ClasspathWildcardIncludeFilter(com.teamscale.report.util.ClasspathWildcardIncludeFilter) Test(org.junit.jupiter.api.Test)

Example 2 with ClasspathWildcardIncludeFilter

use of com.teamscale.report.util.ClasspathWildcardIncludeFilter in project teamscale-jacoco-agent by cqse.

the class JaCoCoXmlReportGeneratorTest method testShrinking.

/**
 * Ensures that uncovered classes are removed from the report if ignore-uncovered-classes is set.
 */
@Test
void testShrinking() throws Exception {
    String testFolderName = "ignore-uncovered-classes";
    long classId = calculateClassId(testFolderName, "TestClass.class");
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    runGenerator(testFolderName, EDuplicateClassFileBehavior.FAIL, true, new ClasspathWildcardIncludeFilter("*", null), createDummyDump(classId)).copy(stream);
    String xmlString = stream.toString(StandardCharsets.UTF_8.name());
    assertThat(xmlString).contains("TestClass");
    assertThat(xmlString).doesNotContain("TestClassTwo");
}
Also used : ClasspathWildcardIncludeFilter(com.teamscale.report.util.ClasspathWildcardIncludeFilter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 3 with ClasspathWildcardIncludeFilter

use of com.teamscale.report.util.ClasspathWildcardIncludeFilter in project teamscale-jacoco-agent by cqse.

the class JaCoCoXmlReportGeneratorTest method testNonShrinking.

/**
 * Ensures that uncovered classes are contained in the report if ignore-uncovered-classes is not set.
 */
@Test
void testNonShrinking() throws Exception {
    String testFolderName = "ignore-uncovered-classes";
    long classId = calculateClassId(testFolderName, "TestClass.class");
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    runGenerator(testFolderName, EDuplicateClassFileBehavior.FAIL, false, new ClasspathWildcardIncludeFilter("*", null), createDummyDump(classId)).copy(stream);
    String xmlString = stream.toString(StandardCharsets.UTF_8.name());
    assertThat(xmlString).contains("TestClassTwo");
}
Also used : ClasspathWildcardIncludeFilter(com.teamscale.report.util.ClasspathWildcardIncludeFilter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.jupiter.api.Test)

Example 4 with ClasspathWildcardIncludeFilter

use of com.teamscale.report.util.ClasspathWildcardIncludeFilter in project teamscale-jacoco-agent by cqse.

the class JaCoCoXmlReportGeneratorTest method testNonEmptyCoverageFileDoesNotThrowException.

@Test
void testNonEmptyCoverageFileDoesNotThrowException() throws IOException, EmptyReportException {
    String testFolderName = "empty-report-handling";
    long classId = calculateClassId(testFolderName, "TestClass.class");
    runGenerator(testFolderName, EDuplicateClassFileBehavior.IGNORE, false, new ClasspathWildcardIncludeFilter("*", null), createDummyDump(classId));
}
Also used : ClasspathWildcardIncludeFilter(com.teamscale.report.util.ClasspathWildcardIncludeFilter) Test(org.junit.jupiter.api.Test)

Example 5 with ClasspathWildcardIncludeFilter

use of com.teamscale.report.util.ClasspathWildcardIncludeFilter in project teamscale-jacoco-agent by cqse.

the class JaCoCoTestwiseReportGeneratorTest method runReportGenerator.

private String runReportGenerator(String testDataFolder, String execFileName) throws Exception {
    File classFileFolder = useTestFile(testDataFolder);
    ClasspathWildcardIncludeFilter includeFilter = new ClasspathWildcardIncludeFilter(null, null);
    TestwiseCoverage testwiseCoverage = new JaCoCoTestwiseReportGenerator(Collections.singletonList(classFileFolder), includeFilter, EDuplicateClassFileBehavior.IGNORE, mock(ILogger.class)).convert(useTestFile(execFileName));
    return ReportUtils.getTestwiseCoverageReportAsString(generateDummyReportFrom(testwiseCoverage));
}
Also used : TestwiseCoverage(com.teamscale.report.testwise.model.TestwiseCoverage) ClasspathWildcardIncludeFilter(com.teamscale.report.util.ClasspathWildcardIncludeFilter) File(java.io.File)

Aggregations

ClasspathWildcardIncludeFilter (com.teamscale.report.util.ClasspathWildcardIncludeFilter)5 Test (org.junit.jupiter.api.Test)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 TestwiseCoverage (com.teamscale.report.testwise.model.TestwiseCoverage)1 File (java.io.File)1