Search in sources :

Example 1 with FileOutput

use of org.jacoco.agent.rt.internal.output.FileOutput in project jacoco by jacoco.

the class FileOutputTest method testWriteData.

@Test
public void testWriteData() throws Exception {
    File destFile = folder.newFile("jacoco.exec");
    AgentOptions options = new AgentOptions();
    options.setDestfile(destFile.getAbsolutePath());
    FileOutput controller = new FileOutput();
    controller.startup(options, new RuntimeData());
    controller.writeExecutionData(false);
    controller.shutdown();
    assertTrue("Execution data file should be created", destFile.exists());
    assertTrue("Execution data file should have contents", destFile.length() > 0);
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) File(java.io.File) FileOutput(org.jacoco.agent.rt.internal.output.FileOutput) AgentOptions(org.jacoco.core.runtime.AgentOptions) Test(org.junit.Test)

Example 2 with FileOutput

use of org.jacoco.agent.rt.internal.output.FileOutput in project jacoco by jacoco.

the class FileOutputTest method testCreateDestFileOnStartup.

@Test
public void testCreateDestFileOnStartup() throws Exception {
    File destFile = folder.newFile("jacoco.exec");
    AgentOptions options = new AgentOptions();
    options.setDestfile(destFile.getAbsolutePath());
    FileOutput controller = new FileOutput();
    controller.startup(options, new RuntimeData());
    assertTrue("Execution data file should be created", destFile.exists());
    assertEquals("Execution data file should be empty", 0, destFile.length());
}
Also used : RuntimeData(org.jacoco.core.runtime.RuntimeData) File(java.io.File) FileOutput(org.jacoco.agent.rt.internal.output.FileOutput) AgentOptions(org.jacoco.core.runtime.AgentOptions) Test(org.junit.Test)

Example 3 with FileOutput

use of org.jacoco.agent.rt.internal.output.FileOutput 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) FileOutput(org.jacoco.agent.rt.internal.output.FileOutput) AgentOptions(org.jacoco.core.runtime.AgentOptions) Test(org.junit.Test)

Aggregations

FileOutput (org.jacoco.agent.rt.internal.output.FileOutput)3 AgentOptions (org.jacoco.core.runtime.AgentOptions)3 RuntimeData (org.jacoco.core.runtime.RuntimeData)3 Test (org.junit.Test)3 File (java.io.File)2