use of org.jacoco.core.data.SessionInfoStore in project dspot by STAMP-project.
the class JacocoExecutor method executeJacoco.
public CoverageResults executeJacoco(CtType<?> testClass) {
final String testClassesDirectory = this.program.getProgramDir() + "/" + this.program.getTestClassesDir();
final RuntimeData data = new RuntimeData();
final ExecutionDataStore executionData = new ExecutionDataStore();
final SessionInfoStore sessionInfos = new SessionInfoStore();
URLClassLoader classLoader;
try {
classLoader = new URLClassLoader(new URL[] { new File(testClassesDirectory).toURI().toURL() }, this.internalClassLoader);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
final String resource = testClass.getQualifiedName().replace('.', '/') + ".class";
try {
this.internalClassLoader.addDefinition(testClass.getQualifiedName(), IOUtils.toByteArray(classLoader.getResourceAsStream(resource)));
runtime.startup(data);
final TestListener listener = TestLauncher.run(this.configuration, this.internalClassLoader, testClass);
if (!listener.getFailingTests().isEmpty()) {
LOGGER.warn("Some test(s) failed during computation of coverage:" + AmplificationHelper.LINE_SEPARATOR + listener.getFailingTests().stream().map(Failure::toString).collect(Collectors.joining(AmplificationHelper.LINE_SEPARATOR)));
}
data.collect(executionData, sessionInfos, false);
runtime.shutdown();
clearCache(this.internalClassLoader);
return coverageResults(executionData);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.jacoco.core.data.SessionInfoStore in project powermock by powermock.
the class JacocoCoverageTest method getExecutionDataStore.
private ExecutionDataStore getExecutionDataStore(RuntimeData data) {
final ExecutionDataStore executionData = new ExecutionDataStore();
final SessionInfoStore sessionInfos = new SessionInfoStore();
data.collect(executionData, sessionInfos, false);
return executionData;
}
Aggregations