Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java-reporter-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<groupId>io.testomat</groupId>
<artifactId>java-reporter-core</artifactId>
<version>0.11.5</version>
<version>0.11.6</version>
<packaging>jar</packaging>

<name>Testomat.io Reporter Core</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Default implementation of {@link RequestBodyBuilder} for Testomat.io API requests.
* Handles JSON serialization and payload structure creation for all API endpoints
* with support for parameterized tests, shared runs, and configurable properties.
*/
public class NativeRequestBodyBuilder implements RequestBodyBuilder {
private static final Logger log = LoggerFactory.getLogger(NativeRequestBodyBuilder.class);

private static final String TRUE = "true";
private final Boolean createParam;
private final String sharedRun;
Expand Down Expand Up @@ -162,7 +166,7 @@ private Map<String, Object> buildTestResultMap(TestResult result) throws JsonPro
result.getSteps().forEach(this::processStepArtifacts);
List<Map<String, Object>> stepsMap = convertStepsToMap(result.getSteps());
body.put("steps", stepsMap);
System.out.println("DEBUG: Adding " + result.getSteps().size() + " steps to request body for test: " + result.getTitle());
log.debug("Adding {} steps to request body for test: {}", result.getSteps().size(), result.getTitle());
}

if (createParam) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.testomat.core.constants;

public class CommonConstants {
public static final String REPORTER_VERSION = "0.11.5";
public static final String REPORTER_VERSION = "0.11.6";

public static final String TESTS_STRING = "tests";
public static final String API_KEY_STRING = "api_key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ public void uploadAllArtifactsForTest(String testName, String rid, String testId
}

S3Credentials credentials = CredentialsManager.getCredentials();
List<String> uploadedArtifactsLinks = processArtifacts(artifactDirectories, testName, rid, credentials);

if (!TempArtifactDirectoriesStorage.STEP_DIRECTORIES.isEmpty()) {
processStepArtifacts(testName, rid, credentials);
List<String> directories = prepareStepArtifactsForUpload(testName, rid, credentials);
processArtifacts(directories, testName, rid, credentials);
}

storeArtifactLinkData(testName, rid, testId, uploadedArtifactsLinks);
if (!artifactDirectories.isEmpty()) {
List<String> uploadedArtifactsLinks = processArtifacts(artifactDirectories, testName, rid, credentials);
storeArtifactLinkData(testName, rid, testId, uploadedArtifactsLinks);

// Clear artifact directories after processing
TempArtifactDirectoriesStorage.DIRECTORIES.remove();
// Clear artifact directories after processing
TempArtifactDirectoriesStorage.DIRECTORIES.remove();
}
}

private List<String> processArtifacts(List<String> artifactDirectories, String testName, String rid, S3Credentials credentials) {
Expand All @@ -99,16 +102,30 @@ private List<String> processArtifacts(List<String> artifactDirectories, String t
return uploadedLinks;
}

private void processStepArtifacts(String testName, String rid, S3Credentials credentials) {
TempArtifactDirectoriesStorage.STEP_DIRECTORIES
.forEach((stepId, list) -> list.replaceAll(dir -> {
if (dir.startsWith("http")) {
return dir;
/**
* Replaces local artifact paths with S3 URLs in STEP_DIRECTORIES
* and returns the list of directories that need to be uploaded.
*
* <p>Only non-HTTP paths are processed, since HTTP entries are already uploaded.</p>
*
* <p>Mutates underlying lists by updating entries in place.</p>
*/
private List<String> prepareStepArtifactsForUpload(String testName, String rid, S3Credentials credentials) {
List<String> artifactDirectories = new ArrayList<>();

for (List<String> list : TempArtifactDirectoriesStorage.STEP_DIRECTORIES.values()) {
for (int i = 0; i < list.size(); i++) {
String dir = list.get(i);

if (!dir.startsWith("http")) {
artifactDirectories.add(dir);
String key = keyGenerator.generateKey(dir, rid, testName);
list.set(i, urlGenerator.generateUrl(credentials.getBucket(), key));
}
String key = keyGenerator.generateKey(dir, rid, testName);
uploadArtifact(dir, key, credentials);
return urlGenerator.generateUrl(credentials.getBucket(), key);
}));
}
}

return artifactDirectories;
}

private void storeArtifactLinkData(String testName, String rid, String testId, List<String> uploadedLinks) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public class GlobalRunManager {
private static final Logger log = LoggerFactory.getLogger(GlobalRunManager.class);
private static final int DELAY_BEFORE_ARTIFACTS_SENDING_MS = 10000;
private static final int DELAY_BEFORE_ARTIFACTS_SENDING_MS = getDelayBeforeArtifactsSendingMs();
private static volatile GlobalRunManager INSTANCE;

private final PropertyProvider provider;
Expand Down Expand Up @@ -347,4 +347,25 @@ private boolean isReportingDisabled() {
return false;
}
}

/**
* Returns the delay before sending artifacts in milliseconds.
*
* <p>Reads the value from the {@code artifacts.sending.delay} system property.
* If the property is missing, non-numeric, or not positive, a default value is used.</p>
*/
private static int getDelayBeforeArtifactsSendingMs() {
int defaultDelayMs = 10000;
String value = System.getProperty("artifacts.sending.delay");
if (value == null) {
return defaultDelayMs;
}
try {
int delayMs = Integer.parseInt(value.trim());
return delayMs > 0 ? delayMs : defaultDelayMs;
} catch (NumberFormatException nfe) {
log.warn("Invalid artifacts.sending.delay value: {}, using default {}", value, defaultDelayMs);
return defaultDelayMs;
}
}
}
2 changes: 1 addition & 1 deletion java-reporter-cucumber/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>io.testomat</groupId>
<artifactId>java-reporter-core</artifactId>
<version>0.11.5</version>
<version>0.11.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
2 changes: 1 addition & 1 deletion java-reporter-junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>io.testomat</groupId>
<artifactId>java-reporter-core</artifactId>
<version>0.11.5</version>
<version>0.11.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
2 changes: 1 addition & 1 deletion java-reporter-karate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>io.testomat</groupId>
<artifactId>java-reporter-core</artifactId>
<version>0.11.5</version>
<version>0.11.6</version>
</dependency>
<dependency>
<groupId>io.karatelabs</groupId>
Expand Down
2 changes: 1 addition & 1 deletion java-reporter-testng/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>io.testomat</groupId>
<artifactId>java-reporter-core</artifactId>
<version>0.11.5</version>
<version>0.11.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
4 changes: 2 additions & 2 deletions testomat-allure-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.testomat</groupId>
<artifactId>testomat-allure-adapter</artifactId>
<version>0.0.2</version>
<version>0.0.3</version>
<packaging>jar</packaging>

<name>Testomat.io Testomat Allure adapter</name>
Expand Down Expand Up @@ -66,7 +66,7 @@
<dependency>
<groupId>io.testomat</groupId>
<artifactId>java-reporter-core</artifactId>
<version>0.11.5</version>
<version>0.11.6</version>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.testomat.reporter;

import io.qameta.allure.listener.StepLifecycleListener;
import io.qameta.allure.model.StatusDetails;
import io.qameta.allure.model.StepResult;
import io.testomat.core.step.StepLifecycle;
import io.testomat.core.step.StepStatus;
import io.testomat.core.step.TestStep;
import java.util.Objects;

/**
* Step lifecycle listener that reports Allure steps to Testomat.
Expand All @@ -21,11 +23,19 @@ public void afterStepStart(StepResult result) {
@Override
public void afterStepStop(StepResult result) {
TestStep testStep = StepLifecycle.current();

if (testStep == null) {
return;
}

testStep.setCategory("user");
testStep.setStepTitle(result.getName());
testStep.setStepTitle(Objects.requireNonNullElse(result.getName(), ""));

long durationMillis = result.getStop() - result.getStart();
testStep.setDuration(durationMillis);
Long start = result.getStart();
Long stop = result.getStop();
long duration = (start != null && stop != null) ? (stop - start) : 0L;

testStep.setDuration(duration);

switch (result.getStatus()) {
case PASSED:
Expand All @@ -34,8 +44,16 @@ public void afterStepStop(StepResult result) {
case FAILED:
case BROKEN:
testStep.setStatus(StepStatus.failed);
testStep.setError(result.getStatusDetails().getMessage());
testStep.setLog(result.getStatusDetails().getTrace());

StatusDetails details = result.getStatusDetails();
if (details != null) {
if (details.getMessage() != null) {
testStep.setError(details.getMessage());
}
if (details.getTrace() != null) {
testStep.setLog(details.getTrace());
}
}
break;
default:
testStep.setStatus(StepStatus.none);
Expand Down
Loading
Loading