Search in sources :

Example 6 with AgentOptions

use of com.teamscale.jacoco.agent.options.AgentOptions in project teamscale-jacoco-agent by cqse.

the class CoverageToTeamscaleStrategyTest method shouldRecordCoverageForTestsEvenIfNotProvidedAsAvailableTest.

@Test
public void shouldRecordCoverageForTestsEvenIfNotProvidedAsAvailableTest() throws Exception {
    AgentOptions options = mockOptions();
    CoverageToTeamscaleStrategy strategy = new CoverageToTeamscaleStrategy(controller, options, reportGenerator);
    TestwiseCoverage testwiseCoverage = getDummyTestwiseCoverage("mytest");
    when(reportGenerator.convert(any(File.class))).thenReturn(testwiseCoverage);
    // we skip testRunStart and don't provide any available tests
    strategy.testStart("mytest");
    strategy.testEnd("mytest", new TestExecution("mytest", 0L, ETestExecutionResult.PASSED));
    strategy.testRunEnd();
    verify(client).uploadReport(eq(EReportFormat.TESTWISE_COVERAGE), matches("\\Q{\"tests\":[{\"duration\":\\E[^,]*\\Q,\"paths\":[{\"files\":[{\"coveredLines\":\"1-4\",\"fileName\":\"Main.java\"}],\"path\":\"src/main/java\"}],\"result\":\"PASSED\",\"sourcePath\":\"mytest\",\"uniformPath\":\"mytest\"}]}\\E"), any(), any(), any(), any());
}
Also used : TestwiseCoverage(com.teamscale.report.testwise.model.TestwiseCoverage) TestExecution(com.teamscale.report.testwise.model.TestExecution) File(java.io.File) AgentOptions(com.teamscale.jacoco.agent.options.AgentOptions) PrioritizableTest(com.teamscale.client.PrioritizableTest) Test(org.junit.jupiter.api.Test)

Example 7 with AgentOptions

use of com.teamscale.jacoco.agent.options.AgentOptions in project teamscale-jacoco-agent by cqse.

the class TestwiseCoverageAgentTest method mockOptions.

private AgentOptions mockOptions(int port) {
    AgentOptions options = mock(AgentOptions.class);
    when(options.createTeamscaleClient()).thenReturn(client);
    TeamscaleServer server = new TeamscaleServer();
    server.commit = new CommitDescriptor("branch", "12345");
    server.url = HttpUrl.get("http://doesnt-exist.io");
    server.userName = "build";
    server.userAccessToken = "token";
    server.partition = "partition";
    when(options.getTeamscaleServerOptions()).thenReturn(server);
    when(options.getHttpServerPort()).thenReturn(port);
    when(options.getTestwiseCoverageMode()).thenReturn(ETestwiseCoverageMode.TEAMSCALE_UPLOAD);
    when(options.createTeamscaleClient()).thenReturn(client);
    return options;
}
Also used : TeamscaleServer(com.teamscale.client.TeamscaleServer) CommitDescriptor(com.teamscale.client.CommitDescriptor) AgentOptions(com.teamscale.jacoco.agent.options.AgentOptions)

Aggregations

AgentOptions (com.teamscale.jacoco.agent.options.AgentOptions)7 File (java.io.File)4 PrioritizableTest (com.teamscale.client.PrioritizableTest)3 Test (org.junit.jupiter.api.Test)3 ClusteredTestDetails (com.teamscale.client.ClusteredTestDetails)2 CommitDescriptor (com.teamscale.client.CommitDescriptor)2 PrioritizableTestCluster (com.teamscale.client.PrioritizableTestCluster)2 TeamscaleServer (com.teamscale.client.TeamscaleServer)2 TestExecution (com.teamscale.report.testwise.model.TestExecution)2 TestwiseCoverage (com.teamscale.report.testwise.model.TestwiseCoverage)2 JacocoRuntimeController (com.teamscale.jacoco.agent.JacocoRuntimeController)1 AgentOptionParseException (com.teamscale.jacoco.agent.options.AgentOptionParseException)1 JacocoAgentBuilder (com.teamscale.jacoco.agent.options.JacocoAgentBuilder)1 TestAgentOptionsBuilder (com.teamscale.jacoco.agent.options.TestAgentOptionsBuilder)1 LoggingResources (com.teamscale.jacoco.agent.util.LoggingUtils.LoggingResources)1 RunningTest (com.teamscale.tia.client.RunningTest)1 TestRun (com.teamscale.tia.client.TestRun)1 TestRunWithClusteredSuggestions (com.teamscale.tia.client.TestRunWithClusteredSuggestions)1 TiaAgent (com.teamscale.tia.client.TiaAgent)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1