Skip to content

Commit

Permalink
Call logic fix: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Sep 6, 2024
1 parent 875f389 commit 8e96e7d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'

repositories {
mavenLocal()
mavenCentral()
}

Expand Down
22 changes: 20 additions & 2 deletions src/main/java/com/epam/reportportal/karate/ReportPortalHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.epam.reportportal.karate.utils.BlockingConcurrentHashMap;
import com.epam.reportportal.listeners.ItemStatus;
import com.epam.reportportal.listeners.ItemType;
import com.epam.reportportal.listeners.ListenerParameters;
import com.epam.reportportal.listeners.LogLevel;
import com.epam.reportportal.service.Launch;
Expand Down Expand Up @@ -56,6 +57,7 @@
* ReportPortal test results reporting hook for Karate. This class publish results in the process of test pass.
*/
public class ReportPortalHook implements RuntimeHook {
private static final String FEATURE_TAG = "Feature: ";
private static final Logger LOGGER = LoggerFactory.getLogger(ReportPortalHook.class);
protected final MemoizingSupplier<Launch> launch;
private final BlockingConcurrentHashMap<String, Supplier<Maybe<String>>> featureIdMap = new BlockingConcurrentHashMap<>();
Expand Down Expand Up @@ -164,8 +166,24 @@ protected StartTestItemRQ buildStartFeatureRq(@Nonnull FeatureRuntime fr) {
@Override
public boolean beforeFeature(FeatureRuntime fr) {
featureIdMap.computeIfAbsent(fr.featureCall.feature.getNameForReport(),
f -> new MemoizingSupplier<>(() -> launch.get().startTestItem(buildStartFeatureRq(fr)))
);
f -> new MemoizingSupplier<>(() -> {
StartTestItemRQ rq = buildStartFeatureRq(fr);
if(fr.caller == null) {
return launch.get().startTestItem(rq);
} else {
Maybe<String> scenarioId = scenarioIdMap.get(fr.caller.parentRuntime.scenario.getUniqueId());
if (scenarioId == null) {
LOGGER.error("ERROR: Trying to post unspecified scenario.");
return launch.get().startTestItem(rq);
}
rq.setType(ItemType.STEP.name());
rq.setHasStats(false);
rq.setName(FEATURE_TAG + rq.getName());
Maybe<String> itemId = launch.get().startTestItem(scenarioId, rq);
ReportPortalUtils.sendLog(itemId, rq.getDescription(), LogLevel.INFO);
return itemId;
}
}));
return true;
}

Expand Down

0 comments on commit 8e96e7d

Please sign in to comment.