Search in sources :

Example 1 with JacocoRuntimeController

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

the class CoverageToTeamscaleStrategyTest method testValidCallSequence.

@Test
public void testValidCallSequence() throws Exception {
    List<PrioritizableTestCluster> clusters = Collections.singletonList(new PrioritizableTestCluster("cluster", Collections.singletonList(new PrioritizableTest("mytest"))));
    when(client.getImpactedTests(any(), any(), any(), any(), anyBoolean(), anyBoolean(), anyBoolean())).thenReturn(Response.success(clusters));
    TestwiseCoverage testwiseCoverage = getDummyTestwiseCoverage("mytest");
    when(reportGenerator.convert(any(File.class))).thenReturn(testwiseCoverage);
    AgentOptions options = mockOptions();
    JacocoRuntimeController controller = mock(JacocoRuntimeController.class);
    CoverageToTeamscaleStrategy strategy = new CoverageToTeamscaleStrategy(controller, options, reportGenerator);
    strategy.testRunStart(Collections.singletonList(new ClusteredTestDetails("mytest", "mytest", "content", "cluster")), false, true, true, null);
    strategy.testStart("mytest");
    strategy.testEnd("mytest", new TestExecution("mytest", 0L, ETestExecutionResult.PASSED));
    strategy.testRunEnd();
    verify(client).uploadReport(eq(EReportFormat.TESTWISE_COVERAGE), matches("\\Q{\"tests\":[{\"content\":\"content\",\"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) ClusteredTestDetails(com.teamscale.client.ClusteredTestDetails) JacocoRuntimeController(com.teamscale.jacoco.agent.JacocoRuntimeController) TestExecution(com.teamscale.report.testwise.model.TestExecution) PrioritizableTestCluster(com.teamscale.client.PrioritizableTestCluster) File(java.io.File) AgentOptions(com.teamscale.jacoco.agent.options.AgentOptions) PrioritizableTest(com.teamscale.client.PrioritizableTest) PrioritizableTest(com.teamscale.client.PrioritizableTest) Test(org.junit.jupiter.api.Test)

Aggregations

ClusteredTestDetails (com.teamscale.client.ClusteredTestDetails)1 PrioritizableTest (com.teamscale.client.PrioritizableTest)1 PrioritizableTestCluster (com.teamscale.client.PrioritizableTestCluster)1 JacocoRuntimeController (com.teamscale.jacoco.agent.JacocoRuntimeController)1 AgentOptions (com.teamscale.jacoco.agent.options.AgentOptions)1 TestExecution (com.teamscale.report.testwise.model.TestExecution)1 TestwiseCoverage (com.teamscale.report.testwise.model.TestwiseCoverage)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1