use of com.teamscale.client.ClusteredTestDetails 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());
}
use of com.teamscale.client.ClusteredTestDetails in project teamscale-jacoco-agent by cqse.
the class TestwiseCoverageAgentTest method testAccessViaTiaClientAndReportUploadToTeamscale.
@Test
public void testAccessViaTiaClientAndReportUploadToTeamscale() throws Exception {
List<ClusteredTestDetails> availableTests = Arrays.asList(new ClusteredTestDetails("test1", "test1", "content", "cluster"), new ClusteredTestDetails("test2", "test2", "content", "cluster"));
List<PrioritizableTestCluster> impactedClusters = Collections.singletonList(new PrioritizableTestCluster("cluster", Collections.singletonList(new PrioritizableTest("test2"))));
when(client.getImpactedTests(any(), any(), any(), any(), anyBoolean(), anyBoolean(), anyBoolean())).thenReturn(Response.success(impactedClusters));
when(reportGenerator.convert(any(File.class))).thenReturn(CoverageToTeamscaleStrategyTest.getDummyTestwiseCoverage("test2"));
int port = PORT_COUNTER.incrementAndGet();
AgentOptions options = mockOptions(port);
when(options.createTempFile(any(), any())).thenReturn(new File(tempDir, "test"));
new TestwiseCoverageAgent(options, null, reportGenerator);
TiaAgent agent = new TiaAgent(false, HttpUrl.get("http://localhost:" + port));
TestRunWithClusteredSuggestions testRun = agent.startTestRun(availableTests);
assertThat(testRun.getPrioritizedClusters()).hasSize(1);
assertThat(testRun.getPrioritizedClusters().get(0).tests).hasSize(1);
PrioritizableTest test = testRun.getPrioritizedClusters().get(0).tests.get(0);
assertThat(test.uniformPath).isEqualTo("test2");
RunningTest runningTest = testRun.startTest(test.uniformPath);
runningTest.endTest(new TestRun.TestResultWithMessage(ETestExecutionResult.PASSED, "message"));
testRun.endTestRun();
verify(client).uploadReport(eq(EReportFormat.TESTWISE_COVERAGE), matches("\\Q{\"tests\":[{\"content\":\"content\",\"paths\":[],\"sourcePath\":\"test1\",\"uniformPath\":\"test1\"},{\"content\":\"content\",\"duration\":\\E[^,]*\\Q,\"message\":\"message\",\"paths\":[{\"files\":[{\"coveredLines\":\"1-4\",\"fileName\":\"Main.java\"}],\"path\":\"src/main/java\"}],\"result\":\"PASSED\",\"sourcePath\":\"test2\",\"uniformPath\":\"test2\"}]}\\E"), any(), any(), any(), any());
}
use of com.teamscale.client.ClusteredTestDetails in project teamscale-jacoco-agent by cqse.
the class TestDescriptorUtils method getAvailableTests.
/**
* Returns the {@link AvailableTests} contained within the root {@link TestDescriptor}.
*/
public static AvailableTests getAvailableTests(TestEngine testEngine, TestDescriptor rootTestDescriptor) {
AvailableTests availableTests = new AvailableTests();
ITestDescriptorResolver testDescriptorResolver = TestDescriptorResolverRegistry.getTestDescriptorResolver(testEngine);
TestDescriptorUtils.streamTestRepresentatives(rootTestDescriptor).forEach(testDescriptor -> {
Optional<String> clusterId = testDescriptorResolver.getClusterId(testDescriptor);
Optional<String> uniformPath = testDescriptorResolver.getUniformPath(testDescriptor);
String source = TestDescriptorUtils.getSource(testDescriptor);
if (!uniformPath.isPresent()) {
LOGGER.error(() -> "Unable to determine uniform path for test descriptor: " + testDescriptor);
return;
}
if (!clusterId.isPresent()) {
LOGGER.error(() -> "Unable to determine cluster id path for test descriptor: " + testDescriptor);
return;
}
ClusteredTestDetails testDetails = new ClusteredTestDetails(uniformPath.get(), source, null, clusterId.get());
availableTests.add(testDescriptor.getUniqueId(), testDetails);
});
return availableTests;
}
Aggregations