Skip to content

Commit bb5dd4d

Browse files
Merge pull request #66 from testomatio/cucumber-parametrized-support
Implemented cucumber parametrized tests support
2 parents 1f6cdef + 7a3128d commit bb5dd4d

File tree

14 files changed

+990
-1072
lines changed

14 files changed

+990
-1072
lines changed

java-reporter-core/src/main/java/io/testomat/core/client/NativeApiClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package io.testomat.core.client;
22

3-
import static io.testomat.core.constants.CommonConstants.REPORTER_VERSION;
4-
import static io.testomat.core.constants.CommonConstants.RESPONSE_UID_KEY;
5-
63
import io.testomat.core.client.http.CustomHttpClient;
74
import io.testomat.core.client.request.NativeRequestBodyBuilder;
85
import io.testomat.core.client.request.RequestBodyBuilder;
@@ -18,6 +15,9 @@
1815
import org.slf4j.Logger;
1916
import org.slf4j.LoggerFactory;
2017

18+
import static io.testomat.core.constants.CommonConstants.REPORTER_VERSION;
19+
import static io.testomat.core.constants.CommonConstants.RESPONSE_UID_KEY;
20+
2121
/**
2222
* HTTP client for Testomat.io API operations.
2323
* Handles test run lifecycle and result reporting with proper error handling.
-52.9 KB
Binary file not shown.

java-reporter-cucumber/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.testomat</groupId>
88
<artifactId>java-reporter-cucumber</artifactId>
9-
<version>0.6.8</version>
9+
<version>0.7.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Testomat.io Java Reporter Cucumber</name>
@@ -50,7 +50,7 @@
5050
<dependency>
5151
<groupId>io.testomat</groupId>
5252
<artifactId>java-reporter-core</artifactId>
53-
<version>0.6.462</version>
53+
<version>0.7.2</version>
5454
</dependency>
5555
<dependency>
5656
<groupId>io.cucumber</groupId>
@@ -73,6 +73,12 @@
7373
<version>${junit.version}</version>
7474
<scope>test</scope>
7575
</dependency>
76+
<dependency>
77+
<groupId>org.junit.jupiter</groupId>
78+
<artifactId>junit-jupiter-params</artifactId>
79+
<version>${junit.version}</version>
80+
<scope>test</scope>
81+
</dependency>
7682
<dependency>
7783
<groupId>org.mockito</groupId>
7884
<artifactId>mockito-core</artifactId>
Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,55 @@
11
package io.testomat.cucumber.constructor;
22

3+
import io.cucumber.plugin.event.TestCaseFinished;
34
import io.testomat.core.model.ExceptionDetails;
45
import io.testomat.core.model.TestResult;
5-
import java.io.PrintWriter;
6-
import java.io.StringWriter;
7-
import java.util.Optional;
8-
import org.slf4j.Logger;
9-
import org.slf4j.LoggerFactory;
6+
import io.testomat.cucumber.extractor.TestDataExtractor;
107

118
/**
129
* Constructs test case results from Cucumber test case finished events.
1310
* Extracts exception details from Cucumber result errors when available.
1411
*/
1512
public class CucumberTestResultConstructor {
16-
private static final Logger log = LoggerFactory.getLogger(CucumberTestResultConstructor.class);
1713

18-
public TestResult constructTestRunResult(TestResultWrapper holder) {
19-
validateHolder(holder);
14+
private final TestDataExtractor testDataExtractor;
2015

21-
log.debug("Creating Cucumber test result with exception details for: {}",
22-
holder.getTestMetadata().getTitle());
23-
24-
ExceptionDetails exceptionDetails = extractExceptionDetails(holder);
25-
26-
return TestResult.builder()
27-
.withTitle(holder.getTestMetadata().getTitle())
28-
.withTestId(holder.getTestMetadata().getTestId())
29-
.withSuiteTitle(holder.getTestMetadata().getSuiteTitle())
30-
.withFile(holder.getTestMetadata().getFile())
31-
.withStatus(holder.getStatus())
32-
.withMessage(exceptionDetails.getMessage())
33-
.withStack(exceptionDetails.getStack())
34-
.build();
16+
/**
17+
* Creates a new instance with default test data extractor.
18+
*/
19+
public CucumberTestResultConstructor() {
20+
this.testDataExtractor = new TestDataExtractor();
3521
}
3622

37-
private void validateHolder(TestResultWrapper holder) {
38-
if (holder == null) {
39-
throw new IllegalArgumentException("TestRunResultWrapper cannot be null");
40-
}
41-
if (holder.getTestMetadata() == null) {
42-
throw new IllegalArgumentException("TestMetadata cannot be null");
43-
}
23+
/**
24+
* Creates a new instance with the specified test data extractor.
25+
*
26+
* @param testDataExtractor the test data extractor to use
27+
*/
28+
public CucumberTestResultConstructor(TestDataExtractor testDataExtractor) {
29+
this.testDataExtractor = testDataExtractor;
4430
}
4531

46-
private ExceptionDetails extractExceptionDetails(TestResultWrapper holder) {
47-
return Optional.ofNullable(holder.getCucumberTestCaseFinished())
48-
.map(event -> event.getResult().getError())
49-
.map(this::createExceptionDetails)
50-
.orElse(ExceptionDetails.empty());
51-
}
32+
/**
33+
* Constructs a test result from a Cucumber test case finished event.
34+
* Extracts test metadata, status, and error details from the event.
35+
*
36+
* @param event the Cucumber test case finished event
37+
* @return the constructed test result
38+
*/
39+
public TestResult constructTestRunResult(TestCaseFinished event) {
5240

53-
private ExceptionDetails createExceptionDetails(Throwable throwable) {
54-
String message = throwable.getMessage();
55-
String stack = getStackTrace(throwable);
56-
log.debug("Including error details for failed test");
57-
return new ExceptionDetails(message, stack);
58-
}
41+
ExceptionDetails exceptionDetails = testDataExtractor.extractExceptionDetails(event);
5942

60-
private String getStackTrace(Throwable t) {
61-
StringWriter sw = new StringWriter();
62-
PrintWriter pw = new PrintWriter(sw);
63-
t.printStackTrace(pw);
64-
return sw.toString();
43+
return TestResult.builder()
44+
.withStatus(testDataExtractor.getNormalizedStatus(event))
45+
.withSuiteTitle(event.getTestCase().getUri().toString())
46+
.withExample(testDataExtractor.createExample(event))
47+
.withTestId(testDataExtractor.extractTestId(event))
48+
.withFile(testDataExtractor.extractFileName(event))
49+
.withTitle(testDataExtractor.extractTitle(event))
50+
.withRid(event.getTestCase().getId().toString())
51+
.withMessage(exceptionDetails.getMessage())
52+
.withStack(exceptionDetails.getStack())
53+
.build();
6554
}
6655
}

java-reporter-cucumber/src/main/java/io/testomat/cucumber/constructor/TestResultWrapper.java

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.testomat.cucumber.exception;
2+
3+
public class CucumberListenerException extends RuntimeException {
4+
public CucumberListenerException(String message) {
5+
super(message);
6+
}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.testomat.cucumber.exception;
2+
3+
public class StatusNormalizerException extends RuntimeException {
4+
public StatusNormalizerException(String message) {
5+
super(message);
6+
}
7+
}

java-reporter-cucumber/src/main/java/io/testomat/cucumber/extractor/CucumberMetaDataExtractor.java

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)