Please refer to attached screen shot, with Junit one can see each of the scenario steps results but with TestNG it's not showing the same.
Is it possible with TestNG as well ? Am I missing any configuration, with JUnit it just works.
After doing some research I've found that there are several tickets for this and similar questions on SO. Maybe the following will provide more info.
At the moment, for cucumber-jvm
release version 1.2.5
, features are run as a single TestNG test (as you can see in the image below)
This ticket was open and not long ago and they have added the functionality to run a TestNG test for each scenario (pull request here).
Because these changes are not released yet, in order to get TestNG to run for each scenario, you have to do a few things:
->
here. (I used IntelliJ for this project, same thing can be done in Eclipse)pom.xml
so you can use the master
branch of cucumber-jmv
, and therefore have the latest changes. Below are the changes I've made.<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<parent>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>java-calculator-testng</artifactId>
<packaging>jar</packaging>
<name>Examples: Java Calculator TestNG</name>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>2.0.0-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
src/test/java
, open RunCukesTest
and run it. Here are the results:I'm sure you can apply the testng.xml
to make it run as you wish.
Unfortunatelly for now, steps
are still not shown. Will probably be added in future releases, it's the next logical step.
Hope this answers your question.