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

[TestNG, JUnit] Update testng and junit readme #1340

Merged
merged 3 commits into from
Apr 1, 2018
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
10 changes: 10 additions & 0 deletions junit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ The Cucumber runner acts like a suite of a JUnit tests. As such other JUnit feat
Listeners and Reporters can all be expected to work.

For more information on JUnit, see the [JUnit web site](http://www.junit.org).

## Assume ##

Through [Assume](https://junit.org/junit4/javadoc/4.12/org/junit/Assume.html) JUnit provides:

> a set of methods useful for stating assumptions about the conditions in which a test is meaningful. A failed
assumption does not mean the code is broken, but that the test provides no useful information. The default JUnit
runner skips tests with failing assumptions. Custom runners may behave differently.

The Cucumber runner supports `Assume` and will marked skipped scenarios as skipped.
51 changes: 51 additions & 0 deletions testng/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Cucumber TestNG
==============

Use TestNG to execute cucumber scenarios.

Add the `cucumber-testng` dependency to your pom.

```xml
<dependencies>
[...]
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
[...]
</dependencies>
```

Create an empty class that extends the `AbstractTestNGCucumberTests`.

```java
package cucumber.runtime.testng;

import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;

@CucumberOptions(plugin = "json:target/cucumber-report.json")
public class RunCukesTest extends AbstractTestNGCucumberTests {
}
```

This will execute all scenarios in same package as the runner, by default glue code is also assumed to be in the same
package. The `@CucumberOptions` can be used to provide
[additional configuration](https://cucumber.io/docs/reference/jvm#list-configuration-options) to the runner.


## Test composition ##

It is possible to use TestNG without inheriting from `AbstractTestNGCucumberTests` by using the `TestNGCucumberRunner`.
See the [RunCukesByCompositionTest Example](../examples/java-calculator-testng/src/test/java/cucumber/examples/java/calculator/RunCukesByCompositionTest.java)
for usage.

## SkipException ##

Cucumber provides limited support for [SkipException](https://jitpack.io/com/github/cbeust/testng/master/javadoc/org/testng/SkipException.html).

* Throwing a `SkipException` results in both Cucumber and TestNG marking the test as skipped.
* Throwing a subclass of `SkipException` results in Cucumber marking the test as failed and TestNG marking the test
as skipped.