Skip to content

Commit

Permalink
Merge pull request #41 from reportportal/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
HardNorth authored Jan 19, 2024
2 parents 26a0ff1 + a7d21bf commit f1bf178
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 196 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## [Unreleased]
### Changed
- Client version updated on [5.2.0](https://github.com/reportportal/client-java/releases/tag/5.2.0), by @HardNorth
### Removed
- Deprecated code, by @HardNorth

## [5.2.0]
### Changed
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Reportportal agent for Cucumber v.6
# ReportPortal agent for Cucumber v.6 and v.7
Cucumber JVM version [6.0.0; ) adapter

> **DISCLAIMER**: We use Google Analytics for sending anonymous usage information such as agent's and client's names, and their versions
> after a successful launch start. This information might help us to improve both ReportPortal backend and client sides. It is used by the
> ReportPortal team only and is not supposed for sharing with 3rd parties.
> **DISCLAIMER**: We use Google Analytics for sending anonymous usage information such as agent's and client's names,
> and their versions after a successful launch start. This information might help us to improve both ReportPortal
> backend and client sides. It is used by the ReportPortal team only and is not supposed for sharing with 3rd parties.
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-cucumber6.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22agent-java-cucumber6%22)
[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-cucumber6.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/agent-java-cucumber6)
[![CI Build](https://github.com/reportportal/agent-java-cucumber6/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-cucumber6/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/reportportal/agent-java-cucumber6/branch/develop/graph/badge.svg?token=GDQZ46X0H0)](https://codecov.io/gh/reportportal/agent-java-cucumber6)
[![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/)
Expand Down
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ repositories {
}

dependencies {
api 'com.epam.reportportal:client-java:5.1.22'
api 'com.epam.reportportal:client-java:5.2.1'
api 'com.epam.reportportal:commons-model:5.0.0'
api 'com.google.code.findbugs:jsr305:3.0.2'

implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation "io.cucumber:cucumber-gherkin:${project.cucumber_version}"
implementation 'org.slf4j:slf4j-api:2.0.4'
implementation 'org.slf4j:slf4j-api:2.0.7'

testImplementation "io.cucumber:cucumber-java:${project.cucumber_version}"
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.2'
Expand All @@ -53,8 +54,8 @@ dependencies {
testImplementation 'org.hamcrest:hamcrest-core:2.2'
testImplementation 'org.mockito:mockito-core:3.3.3'
testImplementation 'org.mockito:mockito-junit-jupiter:3.3.3'
testImplementation 'ch.qos.logback:logback-classic:1.4.5'
testImplementation 'com.epam.reportportal:logger-java-logback:5.1.5'
testImplementation 'ch.qos.logback:logback-classic:1.4.12'
testImplementation 'com.epam.reportportal:logger-java-logback:5.2.0'
testImplementation ("org.junit.platform:junit-platform-runner:${project.junit_runner_version}") {
exclude module: 'junit'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=5.2.1-SNAPSHOT
version=5.3.0-SNAPSHOT
description=EPAM Report portal. Cucumber JVM version [6.0.0; ) adapter
cucumber_version=7.13.0
junit_version=5.6.3
Expand Down
73 changes: 35 additions & 38 deletions src/main/java/com/epam/reportportal/cucumber/AbstractReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,24 @@
import com.epam.reportportal.annotations.TestCaseId;
import com.epam.reportportal.annotations.attribute.Attributes;
import com.epam.reportportal.listeners.ItemStatus;
import com.epam.reportportal.listeners.ItemType;
import com.epam.reportportal.listeners.ListenerParameters;
import com.epam.reportportal.message.ReportPortalMessage;
import com.epam.reportportal.service.Launch;
import com.epam.reportportal.service.ReportPortal;
import com.epam.reportportal.service.item.TestCaseIdEntry;
import com.epam.reportportal.service.tree.TestItemTree;
import com.epam.reportportal.utils.*;
import com.epam.reportportal.utils.files.ByteSource;
import com.epam.reportportal.utils.markdown.MarkdownUtils;
import com.epam.reportportal.utils.properties.SystemAttributesExtractor;
import com.epam.reportportal.utils.reflect.Accessible;
import com.epam.ta.reportportal.ws.model.FinishExecutionRQ;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.model.ParameterResource;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ;
import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ;
import com.google.common.io.ByteSource;
import io.cucumber.core.gherkin.Feature;
import io.cucumber.plugin.ConcurrentEventListener;
import io.cucumber.plugin.event.*;
Expand All @@ -46,8 +49,6 @@
import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.*;
Expand All @@ -58,7 +59,6 @@
import static com.epam.reportportal.cucumber.Utils.*;
import static com.epam.reportportal.cucumber.util.ItemTreeUtils.createKey;
import static com.epam.reportportal.cucumber.util.ItemTreeUtils.retrieveLeaf;
import static java.util.Optional.of;
import static java.util.Optional.ofNullable;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace;
Expand All @@ -74,6 +74,7 @@ public abstract class AbstractReporter implements ConcurrentEventListener {

private static final String NO_NAME = "No name";
private static final String AGENT_PROPERTIES_FILE = "agent.properties";
private static final String DEFINITION_MATCH_FIELD_NAME = "definitionMatch";
private static final String STEP_DEFINITION_FIELD_NAME = "stepDefinition";
private static final String GET_LOCATION_METHOD_NAME = "getLocation";
private static final String COLON_INFIX = ": ";
Expand Down Expand Up @@ -448,27 +449,18 @@ protected void afterStep(@Nonnull TestCase testCase, @Nonnull TestStep testStep,
*/
@Nonnull
protected Pair<String, String> getHookTypeAndName(@Nonnull HookType hookType) {
String name = null;
String type = null;
switch (hookType) {
case BEFORE:
name = "Before hooks";
type = "BEFORE_TEST";
break;
return Pair.of(ItemType.BEFORE_TEST.name(), "Before hooks");
case AFTER:
name = "After hooks";
type = "AFTER_TEST";
break;
return Pair.of(ItemType.AFTER_TEST.name(), "After hooks");
case AFTER_STEP:
name = "After step";
type = "AFTER_METHOD";
break;
return Pair.of(ItemType.AFTER_METHOD.name(), "After step");
case BEFORE_STEP:
name = "Before step";
type = "BEFORE_METHOD";
break;
return Pair.of(ItemType.BEFORE_METHOD.name(), "Before step");
default:
return Pair.of(ItemType.TEST.name(), "Hook");
}
return Pair.of(type, name);
}

/**
Expand Down Expand Up @@ -976,7 +968,7 @@ protected String mapLevel(@Nullable Status cukesStatus) {
*/
@Nonnull
protected String formatDataTable(@Nonnull final List<List<String>> table) {
return Utils.formatDataTable(table);
return MarkdownUtils.formatDataTable(table);
}

/**
Expand Down Expand Up @@ -1019,26 +1011,31 @@ protected String buildMultilineArgument(@Nonnull TestStep step) {
*/
@Nullable
protected String getCodeRef(@Nonnull TestStep testStep) {
return ofNullable(getDefinitionMatchField(testStep)).flatMap(match -> {
try {
Object stepDefinitionMatch = match.get(testStep);
Field stepDefinitionField = stepDefinitionMatch.getClass().getDeclaredField(STEP_DEFINITION_FIELD_NAME);
stepDefinitionField.setAccessible(true);
Object javaStepDefinition = stepDefinitionField.get(stepDefinitionMatch);
Method getLocationMethod = javaStepDefinition.getClass().getMethod(GET_LOCATION_METHOD_NAME);
getLocationMethod.setAccessible(true);
return of(String.valueOf(getLocationMethod.invoke(javaStepDefinition))).filter(r -> !r.isEmpty()).map(r -> {
int openingBracketIndex = r.indexOf(METHOD_OPENING_BRACKET);
if (openingBracketIndex > 0) {
return r.substring(0, r.indexOf(METHOD_OPENING_BRACKET));
} else {
return r;
String cucumberLocation = testStep.getCodeLocation();
try {
Object stepDefinitionMatch = Accessible.on(testStep).field(DEFINITION_MATCH_FIELD_NAME).getValue();
if (stepDefinitionMatch != null) {
Object javaStepDefinition = Accessible.on(stepDefinitionMatch).field(STEP_DEFINITION_FIELD_NAME).getValue();
if (javaStepDefinition != null) {
Object codeLocationObject = Accessible.on(javaStepDefinition).method(GET_LOCATION_METHOD_NAME).invoke();
if (codeLocationObject != null) {
String codeLocation = codeLocationObject.toString();
if (isNotBlank(codeLocation)) {
int openingBracketIndex = codeLocation.indexOf(METHOD_OPENING_BRACKET);
if (openingBracketIndex > 0) {
return codeLocation.substring(0, codeLocation.indexOf(METHOD_OPENING_BRACKET));
} else {
return codeLocation;
}
}
}
});
} catch (NoSuchFieldException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignore) {
}
}
return Optional.empty();
}).orElseGet(testStep::getCodeLocation);
} catch (Throwable e) {
LOGGER.error("Unable to get java code reference for the Test Step: " + cucumberLocation, e);
return cucumberLocation;
}
return cucumberLocation;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.epam.reportportal.cucumber;

import com.epam.reportportal.listeners.ItemType;
import com.epam.reportportal.utils.MemoizingSupplier;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import io.cucumber.plugin.event.HookTestStep;
Expand Down Expand Up @@ -47,9 +48,9 @@
* @author Vadzim Hushchanskou
*/
public class ScenarioReporter extends AbstractReporter {
private static final String RP_STORY_TYPE = "SUITE";
private static final String RP_TEST_TYPE = "STORY";
private static final String RP_STEP_TYPE = "STEP";
private static final String RP_STORY_TYPE = ItemType.SUITE.name();
private static final String RP_TEST_TYPE = ItemType.STORY.name();
private static final String RP_STEP_TYPE = ItemType.STEP.name();
private static final String DUMMY_ROOT_SUITE_NAME = "Root User Story";

protected MemoizingSupplier<Maybe<String>> rootSuiteId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.epam.reportportal.cucumber;

import com.epam.reportportal.listeners.ItemType;
import io.reactivex.Maybe;

import javax.annotation.Nonnull;
Expand All @@ -37,10 +38,12 @@
* steps!)
*
* @author Vadzim Hushchanskou
* @deprecated Use {@link ScenarioReporter}, since the semantic of this class is completely broken and will be removed
*/
@Deprecated(forRemoval = true, since = "5.3.0")
public class StepReporter extends AbstractReporter {
private static final String RP_STORY_TYPE = "STORY";
private static final String RP_TEST_TYPE = "SCENARIO";
private static final String RP_STORY_TYPE = ItemType.STORY.name();
private static final String RP_TEST_TYPE = ItemType.SCENARIO.name();

public StepReporter() {
super();
Expand Down
Loading

0 comments on commit f1bf178

Please sign in to comment.