Search in sources :

Example 16 with RuntimeData

use of org.jacoco.core.runtime.RuntimeData in project jacoco by jacoco.

the class FileOutputTest method testInvalidDestFile.

@Test(expected = IOException.class)
public void testInvalidDestFile() throws Exception {
    AgentOptions options = new AgentOptions();
    options.setDestfile(folder.newFolder("folder").getAbsolutePath());
    FileOutput controller = new FileOutput();
    // Startup should fail as the file can not be created:
    controller.startup(options, new RuntimeData());
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) AgentOptions(org.jacoco.core.runtime.AgentOptions) Test(org.junit.Test)

Example 17 with RuntimeData

use of org.jacoco.core.runtime.RuntimeData in project jacoco by jacoco.

the class ExecuteInstrumentedCodeScenario method getInstrumentedCallable.

@Override
@SuppressWarnings("unchecked")
protected Callable<Void> getInstrumentedCallable() throws Exception {
    IRuntime runtime = new LoggerRuntime();
    runtime.startup(new RuntimeData());
    final Instrumenter instr = new Instrumenter(runtime);
    final byte[] original = TargetLoader.getClassDataAsBytes(target);
    final byte[] instrumentedBuffer = instr.instrument(original, "");
    final TargetLoader loader = new TargetLoader();
    return (Callable<Void>) loader.add(target, instrumentedBuffer).newInstance();
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) LoggerRuntime(org.jacoco.core.runtime.LoggerRuntime) TargetLoader(org.jacoco.core.test.TargetLoader) Instrumenter(org.jacoco.core.instr.Instrumenter) Callable(java.util.concurrent.Callable) IRuntime(org.jacoco.core.runtime.IRuntime)

Example 18 with RuntimeData

use of org.jacoco.core.runtime.RuntimeData in project powermock by powermock.

the class JacocoCoverageTest method jacocoOfflineInstShouldCalculateCoverageAfterPowerMockTransformation.

@Test
public void jacocoOfflineInstShouldCalculateCoverageAfterPowerMockTransformation() throws Exception {
    final RuntimeData data = new RuntimeData();
    runTargetTest(data);
    final CoverageBuilder coverageBuilder = collectCoverage(getExecutionDataStore(data));
    assertCodeCoverage(coverageBuilder);
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) CoverageBuilder(org.jacoco.core.analysis.CoverageBuilder) Test(org.junit.Test)

Aggregations

RuntimeData (org.jacoco.core.runtime.RuntimeData)18 AgentOptions (org.jacoco.core.runtime.AgentOptions)8 Before (org.junit.Before)7 Test (org.junit.Test)7 IOException (java.io.IOException)5 File (java.io.File)4 SystemPropertiesRuntime (org.jacoco.core.runtime.SystemPropertiesRuntime)4 InstanceNotFoundException (javax.management.InstanceNotFoundException)3 IAgentOutput (org.jacoco.agent.rt.internal.output.IAgentOutput)3 Instrumenter (org.jacoco.core.instr.Instrumenter)3 TestListener (fr.inria.stamp.test.listener.TestListener)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 ExceptionRecorder (org.jacoco.agent.rt.internal.ExceptionRecorder)2 CoverageBuilder (org.jacoco.core.analysis.CoverageBuilder)2 ExecutionDataStore (org.jacoco.core.data.ExecutionDataStore)2 SessionInfoStore (org.jacoco.core.data.SessionInfoStore)2 IRuntime (org.jacoco.core.runtime.IRuntime)2 LoggerRuntime (org.jacoco.core.runtime.LoggerRuntime)2