Skip to content

Made parallel test as default #43

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

Merged
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
* Update `*.conf.js` files inside the `src/test/resources/conf/` directory to update desired capabilities.

## Running your tests
* To run a single test, run `mvn test -P single`
* To run parallel tests, run `mvn test -P parallel`
* To run tests, run `mvn test -P parallel`
* To run local tests, run `mvn test -P local`


Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@
<profiles>
<profile>
<id>single</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
Expand All @@ -122,6 +119,9 @@
</profile>
<profile>
<id>parallel</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
Expand Down
11 changes: 6 additions & 5 deletions src/test/java/com/browserstack/RunWebDriverCucumberTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class RunWebDriverCucumberTests {

private TestNGCucumberRunner testNGCucumberRunner;
private Local local;
private static Local local;
private static final ThreadLocal<ManagedWebDriver> threadLocalWebDriver = new ThreadLocal<>();

@BeforeClass(alwaysRun = true)
Expand All @@ -40,6 +40,11 @@ public void setUpClass() {

private synchronized static void setThreadLocalWebDriver(ManagedWebDriver managedWebDriver) {
threadLocalWebDriver.set(managedWebDriver);
if(Utility.isLocal(managedWebDriver) && local==null){
local = new Local();
Utility.startLocal(local, managedWebDriver);
}

}

public synchronized static ManagedWebDriver getManagedWebDriver() {
Expand All @@ -48,10 +53,6 @@ public synchronized static ManagedWebDriver getManagedWebDriver() {

@Test(groups = "cucumber", description = "Runs Cucumber Feature", dataProvider = "scenarios")
public void feature(PickleWrapper pickleWrapper, FeatureWrapper featureWrapper, ManagedWebDriver managedWebDriver) {
if(Utility.isLocal(managedWebDriver) && local==null){
local = new Local();
Utility.startLocal(local, managedWebDriver);
}
managedWebDriver.setTestName(pickleWrapper.getPickle().getName());
setThreadLocalWebDriver(managedWebDriver);
testNGCucumberRunner.runScenario(pickleWrapper.getPickle());
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/browserstack/util/Utility.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static JSONObject getCombinedCapability(Map<String, String> envCapabiliti
bstackOptions = new JSONObject();
bstackOptions.put("userName", username);
bstackOptions.put("accessKey", accessKey);
bstackOptions.put("source", "cucumber-java:sample-selenium-4:v1.1");
capabilities.put("bstack:options", bstackOptions);
return capabilities;
}
Expand Down