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());
}
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;
}
Aggregations