Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#185: Fixed missed scenarios for BDD #189

Merged
merged 4 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.invictum</groupId>
<artifactId>serenity-reportportal-integration</artifactId>
<version>1.6.0-SNAPSHOT</version>
<version>1.6.2-SNAPSHOT</version>

<packaging>jar</packaging>

Expand All @@ -26,6 +26,11 @@
<email>zim182@gmail.com</email>
<organizationUrl>https://github.com/Invictum</organizationUrl>
</developer>
<developer>
<name>Daria Yershova</name>
<email>dariayershova@icloud.com</email>
<organizationUrl>https://github.com/grey-rain</organizationUrl>
</developer>
</developers>

<scm>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.invictum.reportportal;

import com.github.invictum.reportportal.injector.IntegrationInjector;
import com.github.invictum.reportportal.model.TestType;
import com.github.invictum.reportportal.recorder.TestRecorder;
import com.google.inject.Inject;
import net.thucydides.core.webdriver.ThucydidesWebDriverSupport;
Expand Down Expand Up @@ -129,7 +130,10 @@ public void stepFinished(List<ScreenshotAndHtmlSource> list, ZonedDateTime zoned

@Override
public void testFailed(TestOutcome testOutcome, Throwable throwable) {
// Not used by listener
TestType testType = TestType.byTestSource(testOutcome.getTestSource());
if (testType == TestType.BDD) {
testFinished(testOutcome);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This might be dangerous without extensive testing of all supported bdd style tests.
  2. Might worths to add a unit test for this logic.

}

@Override
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/github/invictum/reportportal/model/TestType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.github.invictum.reportportal.model;

import org.apache.commons.lang3.NotImplementedException;

import java.util.Arrays;

public enum TestType {
BDD("(cucumber|jbehave)"),
JUNIT5("JUnit5");

private final String regexMatcher;

TestType(String regexMatcher) {
this.regexMatcher = regexMatcher;
}

public static TestType byTestSource(String testSource) {
return Arrays.stream(values())
.filter(type -> testSource.toLowerCase().matches(type.regexMatcher))
.findFirst()
.orElseThrow(() -> new NotImplementedException(
String.format("Test source %s is not supported", testSource)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import com.github.invictum.reportportal.*;
import com.github.invictum.reportportal.injector.IntegrationInjector;
import com.github.invictum.reportportal.model.TestType;
import com.google.inject.Injector;
import io.reactivex.Maybe;
import net.thucydides.model.domain.TestOutcome;
Expand Down Expand Up @@ -36,7 +37,8 @@ public TestRecorder(SuiteStorage suiteStorage, Launch launch, LogUnitsHolder hol
*/
public static TestRecorder forTest(TestOutcome testOutcome) {
Injector injector = IntegrationInjector.getInjector();
if (testOutcome.isDataDriven() && testOutcome.getTestSource().toLowerCase().matches("(cucumber|jbehave)")) {
boolean isBdd = TestType.byTestSource(testOutcome.getTestSource()) == TestType.BDD;
if (testOutcome.isDataDriven() && isBdd) {
return injector.getInstance(BddDataDriven.class);
}
return injector.getInstance(Regular.class);
Expand Down
Loading