Skip to content

Cucumber junit4 #53

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
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
91 changes: 0 additions & 91 deletions .github/workflows/maven-workflow-run.yml

This file was deleted.

51 changes: 8 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cucumber Java Browserstack
# Cucumber-Junit4 Java Browserstack
![BrowserStack Logo](https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-header.png?1469004780)

[Cucumber JVM](https://cucumber.io/docs/reference/jvm) Integration with BrowserStack.
Expand All @@ -12,7 +12,6 @@
- Install dependencies `mvn compile`
- To run the test suite having cross-platform with parallelization, run `mvn test -P sample-test`
- To run local tests, run `mvn test -P sample-local-test`
- To view Allure Reports, run `allure serve target/allure-results`

Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)

Expand Down Expand Up @@ -46,54 +45,20 @@ Understand how many parallel sessions you need by using our [Parallel Test Calcu
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>
-javaagent:${com.browserstack:browserstack-java-sdk:jar}
</argLine>
</configuration>
</plugin>
```

### Migrate from Vanilla Cucumber to use Testng Runner
* If you are using Vanilla Cucumber CLI, you can migrate to use TestNG Runner with BrowserStack using the below command :
```
mvn archetype:generate -DarchetypeGroupId=com.browserstack -DarchetypeArtifactId=cucumber-testng-archetype -DarchetypeVersion=1.0 -DgroupId=com.browserstack -DartifactId=cucumber-testng-archetype -Dversion=1.0 -DinteractiveMode=false
```
* Run your tests using `mvn test`
* To use specific `@CucumberOptions` in generated class `BrowserStackCucumberTestNgRunner`, refer - https://javadoc.io/static/io.cucumber/cucumber-testng/5.0.0-RC2/io/cucumber/testng/CucumberOptions.html

## Using Gradle

### Run sample build

- Clone the repository
- Install dependencies `gradle build`
- To run the test suite having cross-platform with parallelization, run `gradle sampleTest`
- To run local tests, run `gradle sampleLocalTest`

Understand how many parallel sessions you need by using our [Parallel Test Calculator](https://www.browserstack.com/automate/parallel-calculator?ref=github)

### Integrate your test suite

* Install dependencies `gradle build`
* Following are the changes required in `gradle.build` -
* Add `compileOnly 'com.browserstack:browserstack-java-sdk:latest.release'` in dependencies
* Fetch Artifact Information and add `jvmArgs` property in tasks *SampleTest* and *SampleLocalTest* :
```
def browserstackSDKArtifact = configurations.compileClasspath.resolvedConfiguration.resolvedArtifacts.find { it.name == 'browserstack-java-sdk' }

task sampleTest(type: Test) {
useTestNG() {
dependsOn cleanTest
useDefaultListeners = true
suites "config/sample-test.testng.xml"
jvmArgs "-javaagent:${browserstackSDKArtifact.file}"
}
}
```

## Notes
* You can view your test results on the [BrowserStack Automate dashboard](https://www.browserstack.com/automate)
2 changes: 1 addition & 1 deletion browserstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildName: browserstack build
buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression}
# Set `framework` of your test suite. Example, `testng`, `cucumber`, `cucumber-testng`
# This property is needed to send test context to BrowserStack (test name, status)
framework: cucumber-testng
framework: cucumber-junit4

# =======================================
# Platforms (Browsers / Devices to test)
Expand Down
57 changes: 0 additions & 57 deletions build.gradle

This file was deleted.

35 changes: 14 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<cucumber.version>7.4.1</cucumber.version>
<cucumber.version>7.8.1</cucumber.version>
<testng.version>7.4.0</testng.version>
<selenium-java.version>4.1.4</selenium-java.version>
<browserstack-local-java.version>1.0.6</browserstack-local-java.version>
<json-simple.version>1.1.1</json-simple.version>
<browserstack-java-sdk.version>LATEST</browserstack-java-sdk.version>
<allure.cucumber5.version>2.20.0</allure.cucumber5.version>
<aspectj.version>1.8.0</aspectj.version>
</properties>

<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
Expand All @@ -37,7 +38,7 @@
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -53,12 +54,6 @@
<version>${browserstack-java-sdk.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.18.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -87,10 +82,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>
-javaagent:${com.browserstack:browserstack-java-sdk:jar}
</argLine>
Expand All @@ -111,9 +110,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>
-javaagent:${com.browserstack:browserstack-java-sdk:jar}
</argLine>
Expand All @@ -135,9 +131,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>
-javaagent:${com.browserstack:browserstack-java-sdk:jar}
</argLine>
Expand Down
12 changes: 8 additions & 4 deletions src/test/java/com/browserstack/RunWebDriverCucumberTests.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package com.browserstack;

import io.cucumber.testng.*;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@CucumberOptions(
glue = "com.browserstack.stepdefs",
features = "src/test/resources/features/test",
plugin = {
"pretty",
"html:reports/tests/cucumber/cucumber-pretty.html",
"testng:reports/tests/cucumber/testng/cucumber.xml",
"junit:reports/tests/cucumber/junit/cucumber.xml",
"json:reports/tests/cucumber/json/cucumberTestReport.json"
}
)
public class RunWebDriverCucumberTests extends AbstractTestNGCucumberTests {}

@RunWith(Cucumber.class)
public class RunWebDriverCucumberTests {
}
Loading