diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6d8ea71..4dc13d2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
# Changelog
+### Changed
+- Examples are not reported in their own separate suite now, they are reported as separate scenarios instead, to conform other BDD framework implementation, by @HardNorth
+- Client version updated on [5.2.2](https://github.com/reportportal/client-java/releases/tag/5.2.2), by @HardNorth
+- JBehave dependency marked as `implementation` to force users specify their own versions, by @HardNorth
## [Unreleased]
+### Changed
+- Client version updated on [5.1.24](https://github.com/reportportal/client-java/releases/tag/5.1.24), by @HardNorth
## [5.2.2]
### Changed
diff --git a/README.md b/README.md
index 9be1b62..2dadd9a 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
> 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-jbehave.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22agent-java-jbehave%22)
+[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-jbehave.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/agent-java-jbehave)
[![CI Build](https://github.com/reportportal/agent-java-jbehave/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-jbehave/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/reportportal/agent-java-jbehave/branch/develop/graph/badge.svg?token=BCglguEcoR)](https://codecov.io/gh/reportportal/agent-java-jbehave)
[![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/)
@@ -44,7 +44,7 @@ folder `src/main/resources` or `src/test/resources` (depending on where your tes
```
rp.endpoint = http://localhost:8080
-rp.uuid = e0e541d8-b1cd-426a-ae18-b771173c545a
+rp.api.key = e0e541d8-b1cd-426a-ae18-b771173c545a
rp.launch = JBehave Tests
rp.project = default_personal
```
@@ -58,6 +58,9 @@ rp.project = default_personal
projects.
* `rp.launch` - a user-selected identifier of test launches.
+The full list of supported properties is located here in client-java library documentation (a common library for all
+Java agents): https://github.com/reportportal/client-java
+
### Build system configuration
#### Maven
@@ -73,7 +76,7 @@ rp.project = default_personal
UTF-8
1.8
1.8
- 4.8.1
+ 5.1.1
**/*Stories.java
-skip
@@ -151,7 +154,7 @@ repositories {
mavenCentral()
}
-def jbehaveVersion = '4.8.1'
+def jbehaveVersion = '5.1.1'
dependencies {
testCompile "org.jbehave:jbehave-core:${jbehaveVersion}"
testCompile "org.jbehave:jbehave-navigator:${jbehaveVersion}"
diff --git a/README_TEMPLATE.md b/README_TEMPLATE.md
index 6df9552..c1e508e 100644
--- a/README_TEMPLATE.md
+++ b/README_TEMPLATE.md
@@ -4,7 +4,7 @@
> 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-jbehave.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.epam.reportportal%22%20AND%20a:%22agent-java-jbehave%22)
+[![Maven Central](https://img.shields.io/maven-central/v/com.epam.reportportal/agent-java-jbehave.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.epam.reportportal/agent-java-jbehave)
[![CI Build](https://github.com/reportportal/agent-java-jbehave/actions/workflows/ci.yml/badge.svg)](https://github.com/reportportal/agent-java-jbehave/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/reportportal/agent-java-jbehave/branch/develop/graph/badge.svg?token=BCglguEcoR)](https://codecov.io/gh/reportportal/agent-java-jbehave)
[![Join Slack chat!](https://slack.epmrpp.reportportal.io/badge.svg)](https://slack.epmrpp.reportportal.io/)
@@ -44,7 +44,7 @@ folder `src/main/resources` or `src/test/resources` (depending on where your tes
```
rp.endpoint = http://localhost:8080
-rp.uuid = e0e541d8-b1cd-426a-ae18-b771173c545a
+rp.api.key = e0e541d8-b1cd-426a-ae18-b771173c545a
rp.launch = JBehave Tests
rp.project = default_personal
```
@@ -58,6 +58,10 @@ rp.project = default_personal
projects.
* `rp.launch` - a user-selected identifier of test launches.
+The full list of supported properties is located here in client-java library documentation (a common library for all
+Java agents): https://github.com/reportportal/client-java
+
+
### Build system configuration
#### Maven
@@ -73,7 +77,7 @@ rp.project = default_personal
UTF-8
1.8
1.8
- 4.8.1
+ 5.1.1
**/*Stories.java
-skip
@@ -151,7 +155,7 @@ repositories {
mavenCentral()
}
-def jbehaveVersion = '4.8.1'
+def jbehaveVersion = '5.1.1'
dependencies {
testCompile "org.jbehave:jbehave-core:${jbehaveVersion}"
testCompile "org.jbehave:jbehave-navigator:${jbehaveVersion}"
diff --git a/build.gradle b/build.gradle
index 40f43cb..a3d5512 100644
--- a/build.gradle
+++ b/build.gradle
@@ -34,17 +34,18 @@ sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
repositories {
+ mavenLocal()
mavenCentral()
}
dependencies {
- api 'com.epam.reportportal:client-java:5.1.22'
+ api 'com.epam.reportportal:client-java:5.2.2'
api 'com.epam.reportportal:commons-model:5.0.0'
- api ("org.jbehave:jbehave-core:${project.jbehave_version}") {
+ api 'com.google.code.findbugs:jsr305:3.0.2'
+ implementation ("org.jbehave:jbehave-core:${project.jbehave_version}") {
exclude group: 'junit'
exclude group: 'org.junit.vintage'
}
- api 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.slf4j:slf4j-api:2.0.7'
testImplementation 'com.epam.reportportal:agent-java-test-utils:0.0.2'
@@ -52,8 +53,8 @@ dependencies {
testImplementation 'org.hamcrest:hamcrest-core:2.2'
testImplementation "org.mockito:mockito-core:${project.mockito_version}"
testImplementation "org.mockito:mockito-junit-jupiter:${project.mockito_version}"
- testImplementation 'ch.qos.logback:logback-classic:1.3.8'
- testImplementation 'com.epam.reportportal:logger-java-logback:5.1.6'
+ testImplementation 'ch.qos.logback:logback-classic:1.3.12'
+ testImplementation 'com.epam.reportportal:logger-java-logback:5.2.0'
testImplementation ("org.junit.platform:junit-platform-runner:${project.junit5_launcher_version}") {
exclude group: 'junit'
}
@@ -65,6 +66,7 @@ dependencies {
exclude group: 'junit'
exclude group: 'org.junit.vintage'
}
+ testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
}
test {
diff --git a/gradle.properties b/gradle.properties
index 6901c9f..141742a 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-version=5.2.3-SNAPSHOT
+version=5.3.0-SNAPSHOT
description=JBehave reporters for Report Portal
-jbehave_version=5.1.1
+jbehave_version=5.2.0
junit5_version=5.8.2
junit5_launcher_version=1.8.2
mockito_version=3.3.3
diff --git a/src/main/java/com/epam/reportportal/jbehave/ReportPortalScenarioStoryReporter.java b/src/main/java/com/epam/reportportal/jbehave/ReportPortalScenarioStoryReporter.java
index e29bbb6..626a4f3 100644
--- a/src/main/java/com/epam/reportportal/jbehave/ReportPortalScenarioStoryReporter.java
+++ b/src/main/java/com/epam/reportportal/jbehave/ReportPortalScenarioStoryReporter.java
@@ -32,7 +32,7 @@
/**
* JBehave Reporter for reporting results into ReportPortal. Reports each Story Scenario as a separate test. That means each Scenario
- * has it's own statistic and each Scenario Step is reported as nested step and does not add test count.
+ * has its own statistic and each Scenario Step is reported as nested step and does not add test count.
*
* @author Vadzim Hushchanskou
*/
@@ -46,9 +46,9 @@ public ReportPortalScenarioStoryReporter(final Supplier launchSupplier,
* {@inheritDoc}
*/
@Nonnull
- protected StartTestItemRQ buildStartExampleRq(@Nonnull final Map example, @Nonnull String codeRef,
+ protected StartTestItemRQ buildStartExampleRq(@Nonnull Scenario scenario, @Nonnull Map example, @Nonnull String codeRef,
@Nullable final Date startTime) {
- StartTestItemRQ rq = super.buildStartExampleRq(example, codeRef, startTime);
+ StartTestItemRQ rq = super.buildStartExampleRq(scenario, example, codeRef, startTime);
rq.setType(ItemType.STEP.name());
rq.setTestCaseId(ofNullable(getTestCaseId(codeRef, null)).map(TestCaseIdEntry::getId).orElse(null));
return rq;
@@ -61,10 +61,8 @@ protected StartTestItemRQ buildStartExampleRq(@Nonnull final Map
@Nonnull
protected StartTestItemRQ buildStartScenarioRq(@Nonnull Scenario scenario, @Nonnull String codeRef, @Nullable final Date startTime) {
StartTestItemRQ rq = super.buildStartScenarioRq(scenario, codeRef, startTime);
- if (!scenario.hasExamplesTable() || scenario.getExamplesTable().getRows().isEmpty()) {
- rq.setTestCaseId(ofNullable(getTestCaseId(codeRef, null)).map(TestCaseIdEntry::getId).orElse(null));
- rq.setType(ItemType.STEP.name());
- }
+ rq.setTestCaseId(ofNullable(getTestCaseId(codeRef, null)).map(TestCaseIdEntry::getId).orElse(null));
+ rq.setType(ItemType.STEP.name());
return rq;
}
diff --git a/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepFormat.java b/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepFormat.java
index af11ffb..cb6bacc 100644
--- a/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepFormat.java
+++ b/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepFormat.java
@@ -24,7 +24,9 @@
* Scenarios will not have it.
*
* @author Vadzim Hushchanskou
+ * @deprecated Use {@link ReportPortalScenarioFormat}, since the semantic of this class is completely broken and will be removed
*/
+@Deprecated
public class ReportPortalStepFormat extends ReportPortalFormat {
public static final ReportPortalStepFormat INSTANCE = new ReportPortalStepFormat();
diff --git a/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepStoryReporter.java b/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepStoryReporter.java
index b2f9f74..4e5fffd 100644
--- a/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepStoryReporter.java
+++ b/src/main/java/com/epam/reportportal/jbehave/ReportPortalStepStoryReporter.java
@@ -25,7 +25,9 @@
* statistic.
*
* @author Vadzim Hushchanskou
+ * @deprecated Use {@link ReportPortalScenarioStoryReporter}, since the semantic of this class is completely broken and will be removed
*/
+@Deprecated
public class ReportPortalStepStoryReporter extends ReportPortalStoryReporter {
public ReportPortalStepStoryReporter(final Supplier launchSupplier, TestItemTree testItemTree) {
super(launchSupplier, testItemTree);
diff --git a/src/main/java/com/epam/reportportal/jbehave/ReportPortalStoryReporter.java b/src/main/java/com/epam/reportportal/jbehave/ReportPortalStoryReporter.java
index d6e4667..1732cf5 100644
--- a/src/main/java/com/epam/reportportal/jbehave/ReportPortalStoryReporter.java
+++ b/src/main/java/com/epam/reportportal/jbehave/ReportPortalStoryReporter.java
@@ -25,6 +25,7 @@
import com.epam.reportportal.service.tree.TestItemTree;
import com.epam.reportportal.utils.StatusEvaluation;
import com.epam.reportportal.utils.TestCaseIdUtils;
+import com.epam.reportportal.utils.markdown.MarkdownUtils;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.ParameterResource;
@@ -38,7 +39,10 @@
import org.apache.commons.lang3.tuple.Pair;
import org.jbehave.core.model.*;
import org.jbehave.core.reporters.NullStoryReporter;
+import org.jbehave.core.steps.StepCreator;
import org.jbehave.core.steps.Timing;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -58,6 +62,8 @@
* @author Vadzim Hushchanskou
*/
public abstract class ReportPortalStoryReporter extends NullStoryReporter {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ReportPortalStoryReporter.class);
+
public static final String CODE_REF = "CODE_REF";
public static final String START_TIME = "START_TIME";
public static final String PARAMETERS = "PARAMETERS";
@@ -67,30 +73,27 @@ public abstract class ReportPortalStoryReporter extends NullStoryReporter {
private static final String CODE_REFERENCE_DELIMITER = "/";
private static final String CODE_REFERENCE_ITEM_TYPE_DELIMITER = ":";
- private static final String PARAMETER_ITEMS_DELIMITER = ";";
private static final String CODE_REFERENCE_ITEM_START = "[";
private static final String CODE_REFERENCE_ITEM_END = "]";
- private static final String EXAMPLE_PATTERN = "Example: %s";
private static final String EXAMPLE_VALUE_PATTERN = "<%s>";
private static final Pattern EXAMPLE_VALUE_MATCH = Pattern.compile("<([^>]*)>");
private static final String EXAMPLE = "EXAMPLE";
private static final String LIFECYCLE = "LIFECYCLE";
- private static final String EXAMPLE_PARAMETER_DELIMITER = PARAMETER_ITEMS_DELIMITER + " ";
- private static final String EXAMPLE_KEY_VALUE_DELIMITER = CODE_REFERENCE_ITEM_TYPE_DELIMITER + " ";
private static final String NO_NAME = "No name";
private static final String BEFORE_STORIES = "BeforeStories";
private static final String AFTER_STORIES = "AfterStories";
private static final String BEFORE_STORY = "BeforeStory";
private static final String AFTER_STORY = "AfterStory";
+ private static final String PARAMETERS_PATTERN = "Parameters:\n\n%s";
private final Deque> structure = new LinkedList<>();
private final Deque stepStack = new LinkedList<>();
private final Supplier launch;
private final TestItemTree itemTree;
- private volatile TestItemTree.TestItemLeaf lastStep;
+ private TestItemTree.TestItemLeaf lastStep;
private static volatile ItemType currentLifecycleTopItemType;
- private volatile ItemType currentLifecycleItemType;
+ private ItemType currentLifecycleItemType;
public ReportPortalStoryReporter(final Supplier launchSupplier, TestItemTree testItemTree) {
launch = launchSupplier;
@@ -243,24 +246,6 @@ protected StartTestItemRQ buildStartScenarioRq(@Nonnull Scenario scenario, @Nonn
return rq;
}
- /**
- * Extension point to customize example names
- *
- * @param example a map of variable name -> variable value
- * @return a name of the given example
- */
- protected String formatExampleName(@Nonnull final Map example) {
- return String.format(EXAMPLE_PATTERN,
- example.entrySet()
- .stream()
- .map(e -> e.getKey() + EXAMPLE_KEY_VALUE_DELIMITER + e.getValue())
- .collect(Collectors.joining(EXAMPLE_PARAMETER_DELIMITER,
- CODE_REFERENCE_ITEM_START,
- CODE_REFERENCE_ITEM_END
- ))
- );
- }
-
/**
* Converts parameters map into Report Portal's {@link ParameterResource} list ready to use in a request to Report Portal
*
@@ -285,20 +270,22 @@ private ParameterResource parameterOf(String key, String value) {
/**
* Extension point to customize test creation event/request
*
+ * @param scenario JBehave scenario object
* @param example an example map
* @param codeRef a step code reference
* @param startTime a step start time which will be passed to RP
* @return Request to ReportPortal
*/
@Nonnull
- protected StartTestItemRQ buildStartExampleRq(@Nonnull final Map example, @Nonnull String codeRef,
+ protected StartTestItemRQ buildStartExampleRq(@Nonnull Scenario scenario, @Nonnull Map example, @Nonnull String codeRef,
@Nullable final Date startTime) {
StartTestItemRQ rq = new StartTestItemRQ();
- rq.setName(formatExampleName(example));
+ rq.setName(getScenarioName(scenario));
rq.setCodeRef(codeRef);
rq.setStartTime(ofNullable(startTime).orElseGet(() -> Calendar.getInstance().getTime()));
rq.setType(ItemType.TEST.name());
rq.setParameters(getStepParameters(example));
+ rq.setDescription(String.format(PARAMETERS_PATTERN, MarkdownUtils.formatDataTable(example)));
return rq;
}
@@ -486,6 +473,7 @@ protected Date getItemDate(@Nullable final TestItemTree.TestItemLeaf parent) {
@Nullable
protected TestItemTree.TestItemLeaf retrieveLeaf() {
final List> leafChain = new ArrayList<>();
+ Entity> parentEntity = null;
for (Entity> entity : structure) {
final ItemType itemType = entity.type();
final Optional> parent = leafChain.isEmpty() ?
@@ -509,6 +497,10 @@ protected TestItemTree.TestItemLeaf retrieveLeaf() {
break;
case SCENARIO:
Scenario scenario = (Scenario) entity.get();
+ if (scenario.hasExamplesTable() && !scenario.getExamplesTable().getRows().isEmpty()) {
+ // Each Example has its own scenario node, no need to wrap them into suite once again
+ break;
+ }
TestItemTree.ItemTreeKey scenarioKey = ItemTreeUtils.createKey(getScenarioName(scenario));
leafChain.add(ImmutablePair.of(scenarioKey, children.computeIfAbsent(scenarioKey, k -> createLeaf(
ItemType.SCENARIO,
@@ -517,11 +509,19 @@ protected TestItemTree.TestItemLeaf retrieveLeaf() {
))));
break;
case SUITE: // type SUITE == an Example
+ if (parentEntity == null) {
+ LOGGER.error("Unable to locate Scenario item for Example, this is not something which is supposed to happen,"
+ + " skipping reporting");
+ break;
+ }
+ Scenario parentScenario = (Scenario) parentEntity.get();
Map example = (Map) entity.get();
+ TestItemTree.ItemTreeKey parentScenarioKey = ItemTreeUtils.createKey(getScenarioName(parentScenario));
TestItemTree.ItemTreeKey exampleKey = ItemTreeUtils.createKey(example);
leafChain.add(ImmutablePair.of(exampleKey, children.computeIfAbsent(exampleKey, k -> {
+ String parentScenarioCodeRef = getCodeRef(parentCodeRef, parentScenarioKey, ItemType.SCENARIO);
TestItemTree.TestItemLeaf leaf = createLeaf(ItemType.SUITE,
- buildStartExampleRq(example, getCodeRef(parentCodeRef, k, ItemType.SUITE), itemDate),
+ buildStartExampleRq(parentScenario, example, getCodeRef(parentScenarioCodeRef, k, ItemType.SUITE), itemDate),
parentLeaf
);
leaf.setAttribute(PARAMETERS, example);
@@ -542,6 +542,7 @@ protected TestItemTree.TestItemLeaf retrieveLeaf() {
));
break;
}
+ parentEntity = entity;
}
return leafChain.isEmpty() ? null : leafChain.get(leafChain.size() - 1).getValue();
}
@@ -573,7 +574,12 @@ protected TestItemTree.TestItemLeaf getLeaf() {
leafChain.add(ImmutablePair.of(storyKey, children.get(storyKey)));
break;
case SCENARIO:
- TestItemTree.ItemTreeKey scenarioKey = ItemTreeUtils.createKey(getScenarioName((Scenario) entity.get()));
+ Scenario scenario = (Scenario) entity.get();
+ if (scenario.hasExamplesTable() && !scenario.getExamplesTable().getRows().isEmpty()) {
+ // Each Example has its own scenario node, no need to wrap them into suite once again
+ continue;
+ }
+ TestItemTree.ItemTreeKey scenarioKey = ItemTreeUtils.createKey(getScenarioName(scenario));
leafChain.add(ImmutablePair.of(scenarioKey, children.get(scenarioKey)));
break;
case SUITE: // type SUITE == an Example
@@ -695,6 +701,14 @@ protected ItemStatus evaluateStatus(@Nullable final ItemStatus currentStatus,
*/
protected void evaluateAndFinishLastItem() {
TestItemTree.TestItemLeaf item = getLeaf();
+ Entity> entity = structure.pollLast();
+ if (entity != null && ItemType.SCENARIO == entity.type()) {
+ Scenario scenario = (Scenario) entity.get();
+ if (scenario.hasExamplesTable() && !scenario.getExamplesTable().getRows().isEmpty()) {
+ // Each Example has its own scenario node, no need to wrap them into suite once again
+ return;
+ }
+ }
ofNullable(item).ifPresent(i -> {
ItemStatus status = i.getStatus();
for (Map.Entry entry : i.getChildItems().entrySet()) {
@@ -706,7 +720,6 @@ protected void evaluateAndFinishLastItem() {
i.setStatus(status);
finishItem(i, status);
});
- structure.pollLast();
}
/**
@@ -814,7 +827,7 @@ protected void simulateStep(@Nonnull String step) {
* Starts story (test suite level) in ReportPortal
*
* @param story JBehave story object
- * @param givenStory whether or not this story is given
+ * @param givenStory whether this story is given
* @see Given Stories
*/
@Override
@@ -1004,9 +1017,9 @@ public void notPerformed(String step) {
}
@Override
- public void pending(String step) {
+ public void pending(StepCreator.PendingStep step) {
ofNullable(stepStack.pollLast()).ifPresent(i -> {
- createPendingSteps(step, i);
+ createPendingSteps(step.stepAsString(), i);
finishStep(i, ItemStatus.SKIPPED);
finishBeforeAfterSuites(i);
});
diff --git a/src/test/java/com/epam/reportportal/jbehave/BaseTest.java b/src/test/java/com/epam/reportportal/jbehave/BaseTest.java
index c1f1a74..37e6520 100644
--- a/src/test/java/com/epam/reportportal/jbehave/BaseTest.java
+++ b/src/test/java/com/epam/reportportal/jbehave/BaseTest.java
@@ -67,8 +67,9 @@
import static org.mockito.Mockito.when;
/**
- * This class shouldn't be like that, since it goes against inheritance philosophy. But this is my try to workaround Mockito context
- * collision issues on virtual environments. Basically, if I made everything right, I will get test failures sporadically.
+ * This class shouldn't be like that, since it goes against inheritance philosophy. But this is my try to workaround
+ * Mockito context collision issues on virtual environments. Basically, if I make everything right, I will get test
+ * failures sporadically.
*/
public class BaseTest {
public static final String ROOT_SUITE_PREFIX = "root_";
@@ -85,8 +86,9 @@ public static ExecutorService testExecutor() {
});
}
- public static void run(@Nonnull final Class> clazz, @Nonnull final Format format, @Nonnull final List stories,
- @Nonnull final StoryParser parser, @Nullable final Object... steps) {
+ public static void run(@Nonnull final Class> clazz, @Nonnull final Format format,
+ @Nonnull final List stories, @Nonnull final StoryParser parser,
+ @Nullable final Object... steps) {
Properties viewResources = new Properties();
Embedder embedder = new Embedder();
@@ -116,12 +118,13 @@ public static void run(@Nonnull final Class> clazz, @Nonnull final Format form
embedder.runStoriesAsPaths(stories);
}
- public void run(@Nonnull final Format format, @Nonnull final List stories, @Nonnull final StoryParser parser,
- @Nullable final Object... steps) {
+ public void run(@Nonnull final Format format, @Nonnull final List stories,
+ @Nonnull final StoryParser parser, @Nullable final Object... steps) {
run(getClass(), format, stories, parser, steps);
}
- public void run(@Nonnull final Format format, @Nonnull final List stories, @Nullable final Object... steps) {
+ public void run(@Nonnull final Format format, @Nonnull final List stories,
+ @Nullable final Object... steps) {
run(format, stories, new RegexStoryParser(), steps);
}
@@ -130,17 +133,21 @@ public void run(@Nonnull final Format format, @Nonnull final String story, @Null
}
public static void mockLaunch(@Nonnull final ReportPortalClient client, @Nullable final String launchUuid,
- @Nullable final String storyUuid, @Nonnull String testClassUuid, @Nonnull String stepUuid) {
+ @Nullable final String storyUuid, @Nonnull String testClassUuid,
+ @Nonnull String stepUuid) {
mockLaunch(client, launchUuid, storyUuid, testClassUuid, Collections.singleton(stepUuid));
}
public static void mockLaunch(@Nonnull final ReportPortalClient client, @Nullable final String launchUuid,
- @Nullable final String storyUuid, @Nonnull String testClassUuid, @Nonnull Collection stepList) {
+ @Nullable final String storyUuid, @Nonnull String testClassUuid,
+ @Nonnull Collection stepList) {
mockLaunch(client, launchUuid, storyUuid, Collections.singletonList(Pair.of(testClassUuid, stepList)));
}
public static > void mockLaunch(@Nonnull final ReportPortalClient client,
- @Nullable final String launchUuid, @Nullable final String storyUuid, @Nonnull final Collection> testSteps) {
+ @Nullable final String launchUuid,
+ @Nullable final String storyUuid,
+ @Nonnull final Collection> testSteps) {
String launch = ofNullable(launchUuid).orElse(CommonUtils.namedId("launch_"));
when(client.startLaunch(any())).thenReturn(Maybe.just(new StartLaunchRS(launch, 1L)));
when(client.finishLaunch(eq(launch), any())).thenReturn(Maybe.just(new OperationCompletionRS()));
@@ -148,14 +155,16 @@ public static > void mockLaunch(@Nonnull final Repo
mockStory(client, storyUuid, testSteps);
}
- public static > void mockStory(@Nonnull final ReportPortalClient client, @Nullable final String storyUuid,
- @Nonnull final Collection> testSteps) {
+ public static > void mockStory(@Nonnull final ReportPortalClient client,
+ @Nullable final String storyUuid,
+ @Nonnull final Collection> testSteps) {
String rootItemId = ofNullable(storyUuid).orElseGet(() -> CommonUtils.namedId(ROOT_SUITE_PREFIX));
mockStories(client, Collections.singletonList(Pair.of(rootItemId, testSteps)));
}
@SuppressWarnings("unchecked")
- public static > void mockStories(@Nonnull final ReportPortalClient client,
+ public static > void mockStories(
+ @Nonnull final ReportPortalClient client,
@Nonnull final List>>> stories) {
if (stories.isEmpty()) {
return;
@@ -177,8 +186,9 @@ public static > void mockStories(@Nonnull final Rep
}
@SuppressWarnings("unchecked")
- public static > void mockScenario(@Nonnull final ReportPortalClient client,
- @Nonnull final String storyUuid, @Nonnull final Collection> testSteps) {
+ public static > void mockScenario(
+ @Nonnull final ReportPortalClient client, @Nonnull final String storyUuid,
+ @Nonnull final Collection> testSteps) {
List> testResponses = testSteps.stream()
.map(Pair::getKey)
.map(uuid -> Maybe.just(new ItemCreatedRS(uuid, uuid)))
@@ -199,9 +209,10 @@ public static > void mockScenario(@Nonnull final Re
Maybe myFirst = stepResponses.get(0);
Maybe[] myOther = stepResponses.subList(1, stepResponses.size()).toArray(new Maybe[0]);
when(client.startTestItem(same(testClassUuid), any())).thenReturn(myFirst, myOther);
- new HashSet<>(test.getValue()).forEach(testMethodUuid -> when(client.finishTestItem(same(testMethodUuid),
- any()
- )).thenReturn(Maybe.just(new OperationCompletionRS())));
+ new HashSet<>(test.getValue()).forEach(testMethodUuid -> when(
+ client.finishTestItem(same(testMethodUuid),
+ any()
+ )).thenReturn(Maybe.just(new OperationCompletionRS())));
}
});
}
@@ -216,7 +227,8 @@ public static void mockNestedSteps(final ReportPortalClient client, final Pair> parentNestedPairs) {
+ public static void mockNestedSteps(final ReportPortalClient client,
+ final List> parentNestedPairs) {
Map> responseOrders = parentNestedPairs.stream()
.collect(Collectors.groupingBy(Pair::getKey, Collectors.mapping(Pair::getValue, Collectors.toList())));
responseOrders.forEach((k, v) -> {
@@ -270,12 +282,19 @@ public static List extractJsonParts(List parts) {
.collect(Collectors.toList());
}
- public static List filterLogs(ArgumentCaptor> logCaptor, Predicate filter) {
- return logCaptor.getAllValues().stream().flatMap(l -> extractJsonParts(l).stream()).filter(filter).collect(Collectors.toList());
+ public static List filterLogs(ArgumentCaptor> logCaptor,
+ Predicate filter) {
+ return logCaptor
+ .getAllValues()
+ .stream()
+ .flatMap(l -> extractJsonParts(l).stream())
+ .filter(filter)
+ .collect(Collectors.toList());
}
- public static void verifyLogged(@Nonnull final ArgumentCaptor> logCaptor, @Nullable final String itemId,
- @Nonnull final LogLevel level, @Nonnull final String message) {
+ public static void verifyLogged(@Nonnull final ArgumentCaptor> logCaptor,
+ @Nullable final String itemId, @Nonnull final LogLevel level,
+ @Nonnull final String message) {
List expectedErrorList = filterLogs(logCaptor,
l -> level.name().equals(l.getLevel()) && l.getMessage() != null && l.getMessage().contains(message)
);
@@ -289,6 +308,6 @@ protected static ParameterResource parameterOf(String key, String value) {
ParameterResource parameterResource = new ParameterResource();
parameterResource.setKey(key);
parameterResource.setValue(value);
- return parameterResource;
+ return parameterResource;
}
}
diff --git a/src/test/java/com/epam/reportportal/jbehave/ExamplesTest.java b/src/test/java/com/epam/reportportal/jbehave/ExamplesTest.java
index 6789063..d52c303 100644
--- a/src/test/java/com/epam/reportportal/jbehave/ExamplesTest.java
+++ b/src/test/java/com/epam/reportportal/jbehave/ExamplesTest.java
@@ -23,6 +23,7 @@
import com.epam.reportportal.service.ReportPortal;
import com.epam.reportportal.service.ReportPortalClient;
import com.epam.reportportal.util.test.CommonUtils;
+import com.epam.reportportal.utils.markdown.MarkdownUtils;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.model.ParameterResource;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
@@ -49,11 +50,9 @@ public class ExamplesTest extends BaseTest {
public static final int STEPS_QUANTITY = 4;
private final String storyId = CommonUtils.namedId("story_");
- private final String scenarioId = CommonUtils.namedId("scenario_");
- private final List exampleIds = Stream.generate(() -> CommonUtils.namedId("example_")).limit(2).collect(Collectors.toList());
-
- private final List> stepIds = exampleIds.stream()
- .flatMap(e -> Stream.generate(() -> Pair.of(e, CommonUtils.namedId("step_"))).limit(STEPS_QUANTITY))
+ private final List scenarioIds = Stream.generate(() -> CommonUtils.namedId("scenario_")).limit(2).collect(Collectors.toList());
+ private final List>> stepIds = scenarioIds.stream()
+ .map(e -> Pair.of(e, Stream.generate(() -> CommonUtils.namedId("step_")).limit(STEPS_QUANTITY).collect(Collectors.toList())))
.collect(Collectors.toList());
private final ReportPortalClient client = mock(ReportPortalClient.class);
@@ -64,15 +63,25 @@ public class ExamplesTest extends BaseTest {
@BeforeEach
public void setupMock() {
- mockLaunch(client, null, storyId, scenarioId, exampleIds);
- mockNestedSteps(client, stepIds);
+ mockLaunch(client, null, storyId, stepIds);
mockBatchLogging(client);
}
- private static final List EXAMPLE_NAMES = asList(
- "Example: [symbol: STK1$; threshold: 10.0; price: 5.0; status: OFF]",
- "Example: [symbol: STK1$; threshold: 10.0; price: 11.0; status: ON]"
+ private static final String EXAMPLE_NAME = "Stock trade alert";
+ //@formatter:off
+ private static final String PARAMETERS_PREFIX =
+ "Parameters:\n\n"
+ + MarkdownUtils.TABLE_INDENT + "|\u00A0symbol\u00A0|\u00A0threshold\u00A0|\u00A0price\u00A0|\u00A0status\u00A0|\n"
+ + MarkdownUtils.TABLE_INDENT + "|--------|-----------|-------|--------|\n"
+ + MarkdownUtils.TABLE_INDENT;
+ //@formatter:on
+
+ private static final List EXAMPLE_DESCRIPTIONS = asList(
+ PARAMETERS_PREFIX
+ + "|\u00A0STK1$\u00A0\u00A0|\u00A0\u00A0\u00A010.0\u00A0\u00A0\u00A0\u00A0|\u00A0\u00A05.0\u00A0\u00A0|\u00A0\u00A0OFF\u00A0\u00A0\u00A0|",
+ PARAMETERS_PREFIX
+ + "|\u00A0STK1$\u00A0\u00A0|\u00A0\u00A0\u00A010.0\u00A0\u00A0\u00A0\u00A0|\u00A011.0\u00A0\u00A0|\u00A0\u00A0\u00A0ON\u00A0\u00A0\u00A0|"
);
private static final List