Skip to content

Commit 658f71d

Browse files
Merge pull request #83 from testomatio/step
Implemented step support
2 parents 02c5656 + f0b75b9 commit 658f71d

File tree

17 files changed

+1235
-35
lines changed

17 files changed

+1235
-35
lines changed

api.txt

Lines changed: 583 additions & 0 deletions
Large diffs are not rendered by default.

java-reporter-core/pom.xml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>io.testomat</groupId>
99
<artifactId>java-reporter-core</artifactId>
10-
<version>0.8.1</version>
10+
<version>0.8.3</version>
1111
<packaging>jar</packaging>
1212

1313
<name>Testomat.io Reporter Core</name>
@@ -47,6 +47,7 @@
4747
<maven.source.plugin.version>3.3.0</maven.source.plugin.version>
4848
<maven.javadoc.plugin.version>3.6.3</maven.javadoc.plugin.version>
4949
<maven-gpg-plugin.version>3.2.7</maven-gpg-plugin.version>
50+
<aspectj.version>1.9.24</aspectj.version>
5051
</properties>
5152

5253
<dependencies>
@@ -67,11 +68,11 @@
6768
<artifactId>jackson-databind</artifactId>
6869
<version>${jackson.version}</version>
6970
</dependency>
70-
<!-- <dependency>-->
71-
<!-- <groupId>software.amazon.awssdk</groupId>-->
72-
<!-- <artifactId>s3</artifactId>-->
73-
<!-- <version>2.33.4</version>-->
74-
<!-- </dependency>-->
71+
<dependency>
72+
<groupId>org.aspectj</groupId>
73+
<artifactId>aspectjweaver</artifactId>
74+
<version>${aspectj.version}</version>
75+
</dependency>
7576
<dependency>
7677
<groupId>software.amazon.awssdk</groupId>
7778
<artifactId>aws-sdk-java</artifactId>
@@ -132,6 +133,10 @@
132133
<include>**/*Test.java</include>
133134
<include>**/*Tests.java</include>
134135
</includes>
136+
<!-- required for tests-->
137+
<argLine>
138+
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
139+
</argLine>
135140
</configuration>
136141
</plugin>
137142

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.testomat.core.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
@Retention(RetentionPolicy.RUNTIME)
9+
@Target(ElementType.METHOD)
10+
public @interface Step {
11+
String value() default "";
12+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import static io.testomat.core.constants.CommonConstants.RESPONSE_UID_KEY;
55

66
import io.testomat.core.artifact.ArtifactLinkDataStorage;
7-
import io.testomat.core.artifact.ReportedTestStorage;
87
import io.testomat.core.artifact.LinkUploadBodyBuilder;
8+
import io.testomat.core.artifact.ReportedTestStorage;
99
import io.testomat.core.artifact.credential.CredentialsManager;
1010
import io.testomat.core.artifact.credential.CredentialsValidationService;
1111
import io.testomat.core.client.http.CustomHttpClient;

java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.testomat.core.model.TestResult;
1818
import io.testomat.core.propertyconfig.impl.PropertyProviderFactoryImpl;
1919
import io.testomat.core.propertyconfig.interf.PropertyProvider;
20+
import io.testomat.core.step.TestStep;
2021
import java.util.ArrayList;
2122
import java.util.HashMap;
2223
import java.util.List;
@@ -126,7 +127,7 @@ public String buildUploadLinksBody(String jsonString) {
126127

127128
/**
128129
* Converts test result to map structure for JSON serialization.
129-
* Includes all standard fields plus support for parameterized test data.
130+
* Includes all standard fields plus support for parameterized test data and test steps.
130131
*/
131132
private Map<String, Object> buildTestResultMap(TestResult result) {
132133
Map<String, Object> body = new HashMap<>();
@@ -156,6 +157,12 @@ private Map<String, Object> buildTestResultMap(TestResult result) {
156157
body.put("rid", result.getRid());
157158
}
158159

160+
if (result.getSteps() != null && !result.getSteps().isEmpty()) {
161+
List<Map<String, Object>> stepsMap = convertStepsToMap(result.getSteps());
162+
body.put("steps", stepsMap);
163+
System.out.println("DEBUG: Adding " + result.getSteps().size() + " steps to request body for test: " + result.getTitle());
164+
}
165+
159166
if (createParam) {
160167
body.put("create", TRUE);
161168
}
@@ -165,6 +172,34 @@ private Map<String, Object> buildTestResultMap(TestResult result) {
165172
return body;
166173
}
167174

175+
/**
176+
* Converts a list of TestStep objects to a list of maps for JSON serialization.
177+
* Each step is converted to match the API format with category, title, duration, and nested steps.
178+
*/
179+
private List<Map<String, Object>> convertStepsToMap(List<TestStep> steps) {
180+
List<Map<String, Object>> stepMaps = new ArrayList<>();
181+
for (TestStep step : steps) {
182+
Map<String, Object> stepMap = new HashMap<>();
183+
184+
if (step.getCategory() != null) {
185+
stepMap.put("category", step.getCategory());
186+
}
187+
188+
if (step.getStepTitle() != null) {
189+
stepMap.put("title", step.getStepTitle());
190+
}
191+
192+
stepMap.put("duration", step.getDuration());
193+
194+
if (step.getSubsteps() != null && !step.getSubsteps().isEmpty()) {
195+
stepMap.put("steps", convertStepsToMap(step.getSubsteps()));
196+
}
197+
198+
stepMaps.add(stepMap);
199+
}
200+
return stepMaps;
201+
}
202+
168203
/**
169204
* Safely retrieves property value, returning null if property is not
170205
* found or any exception occurs.

java-reporter-core/src/main/java/io/testomat/core/model/TestResult.java

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package io.testomat.core.model;
22

3+
import io.testomat.core.step.TestStep;
4+
import java.util.List;
5+
36
/**
47
* Represents a test execution result with metadata for Testomat.io reporting.
58
* Contains test outcome, diagnostic information, and optional parameterized test data.
6-
*
9+
*
710
* <p>Use the {@link Builder} for convenient construction:
811
* <pre>{@code
912
* TestResult result = TestResult.builder()
@@ -17,38 +20,41 @@
1720
public class TestResult {
1821
/** Human-readable test method or scenario name */
1922
private String title;
20-
23+
2124
/** Unique test identifier from Testomat.io test management system */
2225
private String testId;
23-
26+
2427
/** Test suite or test class name containing this test */
2528
private String suiteTitle;
26-
29+
2730
/** Source file path where the test is located */
2831
private String file;
29-
32+
3033
/** Test execution status: "passed", "failed", or "skipped" */
3134
private String status;
32-
35+
3336
/** Error or failure message for failed tests, null for passed tests */
3437
private String message;
35-
38+
3639
/** Stack trace for failed tests, null for passed tests */
3740
private String stack;
38-
41+
3942
/** Parameterized test data or example values for data-driven tests */
4043
private Object example;
41-
44+
4245
/** Run identifier for associating results with specific test execution runs */
4346
private String rid;
4447

48+
/** Test steps executed during the test */
49+
private List<TestStep> steps;
50+
4551
public TestResult() {
4652
}
4753

4854
public TestResult(String title, String testId,
4955
String suiteTitle, String file,
5056
String status, String message, String stack,
51-
Object example, String rid) {
57+
Object example, String rid, List<TestStep> steps) {
5258
this.title = title;
5359
this.testId = testId;
5460
this.suiteTitle = suiteTitle;
@@ -58,6 +64,7 @@ public TestResult(String title, String testId,
5864
this.stack = stack;
5965
this.example = example;
6066
this.rid = rid;
67+
this.steps = steps;
6168
}
6269

6370
/**
@@ -74,6 +81,7 @@ public static class Builder {
7481
private String stack;
7582
private Object example;
7683
private String rid;
84+
private List<TestStep> steps;
7785

7886
public Builder withTitle(String title) {
7987
this.title = title;
@@ -120,8 +128,13 @@ public Builder withRid(String rid) {
120128
return this;
121129
}
122130

131+
public Builder withSteps(List<TestStep> steps) {
132+
this.steps = steps;
133+
return this;
134+
}
135+
123136
public TestResult build() {
124-
return new TestResult(title, testId, suiteTitle, file, status, message, stack, example, rid);
137+
return new TestResult(title, testId, suiteTitle, file, status, message, stack, example, rid, steps);
125138
}
126139
}
127140

@@ -205,4 +218,12 @@ public String getRid() {
205218
public void setRid(String rid) {
206219
this.rid = rid;
207220
}
221+
222+
public List<TestStep> getSteps() {
223+
return steps;
224+
}
225+
226+
public void setSteps(List<TestStep> steps) {
227+
this.steps = steps;
228+
}
208229
}

0 commit comments

Comments
 (0)