I am Unsure how to launch the runner class within Eclipse using AbstractTestNGCucumberTests

658 views
Skip to first unread message

Charles Radley

unread,
Aug 20, 2016, 8:56:11 AM8/20/16
to Cukes

Greetings,

I have posted this question on Stackoverflow site:


I am Unsure how to launch the runner class within Eclipse using AbstractTestNGCucumberTests

I have a project set up, intended to use TestNG to run a Cucumber test suite.

I have followed all the steps in all the docs I can find, but I am unable to launch the runner in a manner which recognizes the testNG annotations in the class, such as @BeforeMethod

The project runs fine as a Junit test if I uncomment the @RunWith line in the runner class, but when I comment the @RunWith, then it does not launch as a TestNG project, and still behaves as a junit project.

If I select the CukesRunner an click "Run-As" there is no run type displayed, and I can only select to run it as Junit from the history record. I can find no way of launching the Cukesrunner such that it invokes the TestNG behavior of the AbstractTestNGCucumberTests class.

The TestNG plugin is working fine on this system, testNG enable projects run fine when they do not include the cucumber nor AbstractTestNGCucumberTests class.

Here are the key components of the project:

testng.xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Cucumber-numbers-game" >
  <test name="Play_Games" >
    <classes>
      <class name="com.example.GameSteps" />  
    </classes>
  </test>
</suite>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>example</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>example</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <repositories>
    <repository>
      <id>sonatype-snapshots</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <dependencies>

      <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>1.2.4</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-junit</artifactId>
      <version>1.1.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-java</artifactId>
      <version>1.1.3</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

CukesRunner.java

package com.example;

import cucumber.api.junit.Cucumber;
// import org.junit.runner.RunWith;
import cucumber.api.testng.AbstractTestNGCucumberTests;

// @RunWith(Cucumber.class)
@Cucumber.Options(
        features={"src/test/resources"}
)
public class CukesRunner extends AbstractTestNGCucumberTests{}

GameSteps.java

package com.example;    
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import org.testng.annotations.*;
import static org.junit.Assert.assertEquals;

public class GameSteps {
    private Game _target;
    private String _actualResult;

    @BeforeMethod
    public void setUp() {
    System.out.println("@BeforeMethod: The annotated method will be run before each test method.");
    }

    @Test

    @Given("^I am officiating a \"([^\"]*)\" game$")
    public void I_am_officiating_a_game(String gameTypeName) {
        System.out.println("^I am officiating a \"([^\"]*)\" game$");
        GameType gameType = GameType.valueOf(gameTypeName);
        _target = GameFactory.createGame(gameType);
    }

    @When("^the number (\\d+) is played$")
    public void the_number_is_played(int playedNumber) {
        System.out.println("^the number (\\d+) is played$");
        _actualResult = _target.checkPlay(playedNumber);
    }

    @Then("^I should be told the correct answer is \"([^\"]*)\"$")
    public void I_should_be_told_the_correct_answer_is(String expectedResult) {
        System.out.println("^I should be told the correct answer is \"([^\"]*)\"$");
        assertEquals(expectedResult, _actualResult);
    }
}

Game.feature

Feature: Number Games
  So that plays can be validated
  As a number game umpire
  I want to enter a play and see the correct answer

  Scenario Outline: A game of FizzBuzz
    Given I am officiating a "FizzBuzz" game
    When the number <played> is played
    Then I should be told the correct answer is "<result>"

  Examples:
    | played | result   |
    | 1      | 1        |
    | 2      | 2        |
    | 3      | Fizz     |
    | 5      | Buzz     |
    | 6      | Fizz     |
    | 10     | Buzz     |
    | 15     | FizzBuzz |

  Scenario Outline: A game of Crash Bang Wallop
    Given I am officiating a "CrashBangWallop" game
    When the number <played> is played
    Then I should be told the correct answer is "<result>"

  Examples:
    | played | result          |
    | 1      | 1               |
    | 2      | 2               |
    | 3      | Crash           |
    | 5      | Bang            |
    | 7      | Wallop          |
    | 15     | CrashBang       |
    | 35     | BangWallop      |
    | 21     | CrashWallop     |
    | 105    | CrashBangWallop |

Attached is a screenshot of the project structure:


Here is a screenshot of the project structure:


numbers-game-project.png

Krishna Gundala

unread,
Aug 20, 2016, 11:06:05 PM8/20/16
to Cukes

http://sahajamit.github.io/Cucumber-JVM-with-TestNG/

Hope this might help you..


--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Charles Radley

unread,
Aug 21, 2016, 8:15:38 AM8/21/16
to cu...@googlegroups.com

Hi Krishna,

I have already read that article, but it is rather confusing and conflicts with other articles I have seen on the internet.

For example, it shows an @RunWith annotation in the runner class, and I believe that is not correct, based on other posts i have seen, since it is a Junit annotation.

Also, the article does not explain how to launch nor invoke the runner from within Eclipse [or any other IDE]....

So no, I am afraid that article does not help at all....

Any other pointers ?


from Charles F Radley
Associate Fellow AIAA
Yahoo = CFRJLR
Skype  = CFRJLR
Landline - voip - ooma - phone = +1-503-922-1012 
Mobile cell: +1-360-773-2595 Boost


To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cukes/90uy0n5FVgI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cukes+unsubscribe@googlegroups.com.

Björn Rasmusson

unread,
Aug 21, 2016, 1:15:42 PM8/21/16
to Cukes
Charles Radley wrote:

Hi Krishna,

I have already read that article, but it is rather confusing and conflicts with other articles I have seen on the internet.

For example, it shows an @RunWith annotation in the runner class, and I believe that is not correct, based on other posts i have seen, since it is a Junit annotation.

Also, the article does not explain how to launch nor invoke the runner from within Eclipse [or any other IDE]....

So no, I am afraid that article does not help at all....

Any other pointers ?


from Charles F Radley
Associate Fellow AIAA
Yahoo = CFRJLR
Skype  = CFRJLR
Landline - voip - ooma - phone = +1-503-922-1012 
Mobile cell: +1-360-773-2595 Boost


On Sat, Aug 20, 2016 at 11:05 PM, Krishna Gundala <gmk....@gmail.com> wrote:

http://sahajamit.github.io/Cucumber-JVM-with-TestNG/

Hope this might help you..


On Sat, Aug 20, 2016, 6:26 PM Charles Radley <cfr...@gmail.com> wrote:

Greetings,

I have posted this question on Stackoverflow site:


I am Unsure how to launch the runner class within Eclipse using AbstractTestNGCucumberTests

I have no idea what Eclipse use to determine that a class should have a "run as" option for TestNG.
 

I have a project set up, intended to use TestNG to run a Cucumber test suite.

I have followed all the steps in all the docs I can find, but I am unable to launch the runner in a manner which recognizes the testNG annotations in the class, such as @BeforeMethod

The TestNG module of Cucumber-JVM is intended to make it possible to just to start Cucumber features from a TestNG runner, you should never use the TestNG annotations like @BeforeMethod in step definition classes (like the GameSteps class below), but Cucumber-JVM annotations like @cucumber.api.java.Before instead.

Regards
Björn
 
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to a topic in the Google Groups "Cukes" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cukes/90uy0n5FVgI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cukes+un...@googlegroups.com.

Charles Radley

unread,
Aug 21, 2016, 5:57:12 PM8/21/16
to cu...@googlegroups.com


Hi Björn, Thanks for your reply it is very helpful.


On 8/21/2016 1:15 PM, Björn Rasmusson wrote:


I am Unsure how to launch the runner class within Eclipse using AbstractTestNGCucumberTests

I have no idea what Eclipse use to determine that a class should have a "run as" option for TestNG.

There is a TestNG plugin for Eclipse; when that is installed, users can highlight any class or object they wish to run and right click on it.  A drop-down appears and TestNG is offered as an option for "run configuration".    If you select TestNG, then eclipse will execute the object and will interpret and act upon any
TestNG annotations it finds in the object.


 

I have a project set up, intended to use TestNG to run a Cucumber test suite.

I have followed all the steps in all the docs I can find, but I am unable to launch the runner in a manner which recognizes the testNG annotations in the class, such as @BeforeMethod

The TestNG module of Cucumber-JVM is intended to make it possible to just to start Cucumber features from a TestNG runner, you should never use the TestNG annotations like @BeforeMethod in step definition classes (like the GameSteps class below), but Cucumber-JVM annotations like @cucumber.api.java.Before instead.


Thanks Björn, I think you was articulated the unspoken issue which I have not found explained anywhere previously, and that is, that there are in fact TWO completely different forms of annotation involved.

1) TestNG annotations which belong in the runner class, and

2) Cucumber-JVM annotations which belong in the steps class.

The examples I have seen of TestNG related steps files include the annotations @Before and @After, and it appeared to me that these were TestNG annotations.  But you have pointed out that they are in fact different animals from a different species.   It would have been nice if that could have been clearly documented somewhere in a definitive javadoc type page.    The so-called docs for TestNG  under cucumber are scattered among a lot of poorly written blog posts, leaving me unsure what to really believe.

Thanks again.

Charles R.




Avast logo

This email has been checked for viruses by Avast antivirus software.
www.avast.com


Paolo Ambrosio

unread,
Aug 22, 2016, 2:58:50 AM8/22/16
to cu...@googlegroups.com
On Sun, Aug 21, 2016 at 1:15 PM, Charles Radley <cfr...@gmail.com> wrote:

Hi Krishna,

I have already read that article, but it is rather confusing and conflicts with other articles I have seen on the internet.

For what I remember of the TestNG integration that article looks pretty accurate. It has a lot of detail on aspects you probably won't need and it assumes that the reader knows how to write Cucumber step definitions (that are never shown).

You might want to take a look at the official example that is much simpler: https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng
 
For example, it shows an @RunWith annotation in the runner class, and I believe that is not correct, based on other posts i have seen, since it is a Junit annotation.

Yes, it shows the @RunWith annotation but that code is introduced by this sentence: "With JUnit, the integration is quite straight forward, we simply need to create a test runner class like this".
 
Also, the article does not explain how to launch nor invoke the runner from within Eclipse [or any other IDE]....

Hope you have a build system (Maven, Gradle, ...) to verify that the code you wrote runs correctly before trying the IDE integration. Or you can try and run an existing working example in the IDE, like the Java Calculator TestNG above.

If you do both at the same time you won't know which part you are getting wrong :-)

Charles Radley

unread,
Aug 22, 2016, 7:10:32 AM8/22/16
to cu...@googlegroups.com


Thanks Paolo.


On 8/22/2016 2:58 AM, Paolo Ambrosio wrote:

You might want to take a look at the official example that is much simpler: https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng

Thanks for that.


 
For example, it shows an @RunWith annotation in the runner class, and I believe that is not correct, based on other posts i have seen, since it is a Junit annotation.

Yes, it shows the @RunWith annotation but that code is introduced by this sentence: "With JUnit, the integration is quite straight forward, we simply need to create a test runner class like this".

That is highly confusing.   the article does not show an example of how to set up a runner with TestNG, only the old method using Junit.

That is very poor writing and unhelpful.


 
Also, the article does not explain how to launch nor invoke the runner from within Eclipse [or any other IDE]....

Hope you have a build system (Maven, Gradle, ...) to verify that the code you wrote runs correctly before trying the IDE integration. Or you can try and run an existing working example in the IDE, like the Java Calculator TestNG above.

I find it more useful to do the opposite.  That is run it in the IDE, before doing command line maven execution.

The IDE presents lots of easy to ready debugging reports, and a nice console to monitor progress.
Maven command line gives a lot of irrelevant build reports which do not interest me in the first instance when working with prototype code.



If you do both at the same time you won't know which part you are getting wrong :-)

Sorry, you lost me there.  My IDE is working fine.

Charles Radley

unread,
Aug 22, 2016, 7:16:09 AM8/22/16
to cu...@googlegroups.com

There is another thing which I do not understand about the TestNg setup
for Cucumber....

What is the purpose of the TestNG.xml file ?

In a standard Cucumber project, e.g using Junit, the project executes
all the steps files whose name correspond to features files
in the resources folder. This method of flow control works well for me.

However, several blog posts I have seen claim that is is necessary to
have a testng.xml file, and that the primary purpose of the testng.xml
file is to
contain tags which identify certain packages, or classes or methods
which need to be executed. That appears to be completely redundant and
pointless, since Cucumber already has a built in process for selecting
which classes to run.

Or does the testng.xml take precedence over the standard Cucumber
behavior ?

I would appreciate some advice about that.

Thanks,

CFR.


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Charles Radley

unread,
Aug 22, 2016, 10:31:49 AM8/22/16
to cu...@googlegroups.com


Hi Paolo,


On 8/22/2016 2:58 AM, Paolo Ambrosio wrote:

From Paolo:



You might want to take a look at the official example that is much simpler: https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng
 


Hope you have a build system (Maven, Gradle, ...) to verify that the code you wrote runs correctly before trying the IDE integration. Or you can try and run an existing working example in the IDE, like the Java Calculator TestNG above.


I use Maven.

I can run the example successfully at the command line, see transcript below.

How do I now run this in the Eclispe IDE ?

C:\test-automation\cucumber-jvm\examples\java-calculator-testng>mvn test -Dtest=RunCukesTest
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Examples: Java Calculator TestNG 1.2.5-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-java/1.2.5-SNAPSHOT/maven-metadata.xml
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-java/1.2.5-SNAPSHOT/maven-metadata.xml (776 B at 0.5 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-java/1.2.5-SNAPSHOT/cucumber-java-1.2.5-20160802.182925-31.pom
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-java/1.2.5-SNAPSHOT/cucumber-java-1.2.5-20160802.182925-31.pom (6 KB at 2
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-jvm/1.2.5-SNAPSHOT/maven-metadata.xml
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-jvm/1.2.5-SNAPSHOT/maven-metadata.xml (601 B at 3.6 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-jvm/1.2.5-SNAPSHOT/cucumber-jvm-1.2.5-20160802.182906-31.pom
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-jvm/1.2.5-SNAPSHOT/cucumber-jvm-1.2.5-20160802.182906-31.pom (39 KB at 12
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-core/1.2.5-SNAPSHOT/maven-metadata.xml
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-core/1.2.5-SNAPSHOT/maven-metadata.xml (776 B at 3.4 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-core/1.2.5-SNAPSHOT/cucumber-core-1.2.5-20160802.182909-31.pom
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-core/1.2.5-SNAPSHOT/cucumber-core-1.2.5-20160802.182909-31.pom (4 KB at 1
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-testng/1.2.5-SNAPSHOT/maven-metadata.xml
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-testng/1.2.5-SNAPSHOT/maven-metadata.xml (778 B at 3.6 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-testng/1.2.5-SNAPSHOT/cucumber-testng-1.2.5-20160802.182927-31.pom
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-testng/1.2.5-SNAPSHOT/cucumber-testng-1.2.5-20160802.182927-31.pom (2 KB
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-java/1.2.5-SNAPSHOT/cucumber-java-1.2.5-20160802.182925-31.jar
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-testng/1.2.5-SNAPSHOT/cucumber-testng-1.2.5-20160802.182927-31.jar
Downloading: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-core/1.2.5-SNAPSHOT/cucumber-core-1.2.5-20160802.182909-31.jar
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-testng/1.2.5-SNAPSHOT/cucumber-testng-1.2.5-20160802.182927-31.jar (11 KB
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-java/1.2.5-SNAPSHOT/cucumber-java-1.2.5-20160802.182925-31.jar (233 KB at
Downloaded: https://oss.sonatype.org/content/repositories/snapshots/info/cukes/cucumber-core/1.2.5-SNAPSHOT/cucumber-core-1.2.5-20160802.182909-31.jar (225 KB at
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ java-calculator-testng ---
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/enforcer/enforcer-api/1.0/enforcer-api-1.0.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-api/1.0/enforcer-api-1.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-api/1.0/enforcer-api-1.0.pom (4 KB at 9.3 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/enforcer/enforcer-rules/1.0/enforcer-rules-1.0.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-rules/1.0/enforcer-rules-1.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-rules/1.0/enforcer-rules-1.0.pom (5 KB at 33.6 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/shared/maven-common-artifact-filters/1.2/maven-common-artifact-filters-1.2.p
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/1.2/maven-common-artifact-filters-1.2.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/1.2/maven-common-artifact-filters-1.2.pom (5 KB at 33.7 KB
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/shared/maven-plugin-testing-harness/1.1/maven-plugin-testing-harness-1.1.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-plugin-testing-harness/1.1/maven-plugin-testing-harness-1.1.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-plugin-testing-harness/1.1/maven-plugin-testing-harness-1.1.pom (7 KB at 73.6 KB/s
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/shared/maven-shared-components/7/maven-shared-components-7.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-components/7/maven-shared-components-7.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-components/7/maven-shared-components-7.pom (3 KB at 25.9 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.pom
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.pom
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.pom (2 KB at 9.6 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom (2 KB at 17.7 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/enforcer/enforcer-api/1.0/enforcer-api-1.0.jar
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/enforcer/enforcer-rules/1.0/enforcer-rules-1.0.jar
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/shared/maven-common-artifact-filters/1.2/maven-common-artifact-filters-1.2.j
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-api/1.0/enforcer-api-1.0.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/1.2/maven-common-artifact-filters-1.2.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-rules/1.0/enforcer-rules-1.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-api/1.0/enforcer-api-1.0.jar (10 KB at 90.3 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/1.2/maven-common-artifact-filters-1.2.jar (31 KB at 149.8
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/enforcer/enforcer-rules/1.0/enforcer-rules-1.0.jar (60 KB at 232.6 KB/sec)
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce) @ java-calculator-testng ---
[INFO] The requirePluginVersions rule is currently not compatible with Maven3.
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ java-calculator-testng ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\test-automation\cucumber-jvm\examples\java-calculator-testng\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ java-calculator-testng ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\test-automation\cucumber-jvm\examples\java-calculator-testng\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ java-calculator-testng ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ java-calculator-testng ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\test-automation\cucumber-jvm\examples\java-calculator-testng\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ java-calculator-testng ---
[INFO] Surefire report directory: C:\test-automation\cucumber-jvm\examples\java-calculator-testng\target\surefire-reports
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/surefire/surefire-testng/2.17/surefire-testng-2.17.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.17/surefire-testng-2.17.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.17/surefire-testng-2.17.pom (3 KB at 26.6 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.pom
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.pom (2 KB at 18.9 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/testng/testng/5.7/testng-5.7.pom
Downloaded: https://oss.sonatype.org/content/repositories/releases/org/testng/testng/5.7/testng-5.7.pom (12 KB at 33.4 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/surefire/surefire-testng/2.17/surefire-testng-2.17.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.17/surefire-testng-2.17.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/common-java5/2.17/common-java5-2.17.jar (37 KB at 276.7 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.17/surefire-testng-2.17.jar (36 KB at 385.9 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/surefire/surefire-testng-utils/2.17/surefire-testng-utils-2.17.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng-utils/2.17/surefire-testng-utils-2.17.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng-utils/2.17/surefire-testng-utils-2.17.jar (29 KB at 278.3 KB/sec)
Downloading: https://oss.sonatype.org/content/repositories/releases/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-grouper/2.17/surefire-grouper-2.17.jar (38 KB at 296.7 KB/sec)

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running cucumber.examples.java.calculator.RunCukesTest
Configuring TestNG with: TestNG652Configurator
Runs before scenarios *not* tagged with @foo
Runs before scenarios *not* tagged with @foo

8 Scenarios (8 passed)
36 Steps (36 passed)
0m0.423s

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.419 sec - in cucumber.examples.java.calculator.RunCukesTest

Results :

Tests run: 3, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25.317 s
[INFO] Finished at: 2016-08-22T10:29:55-04:00
[INFO] Final Memory: 18M/140M
[INFO] ------------------------------------------------------------------------

C:\test-automation\cucumber-jvm\examples\java-calculator-testng>

How do I now run this in the Eclispe IDE ?

Thanks,

CFR.








Avast logo

This email has been checked for viruses by Avast antivirus software.

Charles Radley

unread,
Aug 22, 2016, 12:21:10 PM8/22/16
to cu...@googlegroups.com

Hi Paolo and co,


On 8/22/2016 2:58 AM, Paolo Ambrosio wrote:

From Paolo:

> > You might want to take a look at the official example that is much > simpler: > https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng > > >

The example project above does not include any testng.xml file.....

Does that mean I do not need a testng.xml  file in my cucumber testng projects ?

Is the testng.xml required ?  Is it optional?  Has it been recently deprecated ?

Should I ignore the various blog posts which talk about using a testng.xml file with cucumber ?

Björn Rasmusson

unread,
Aug 22, 2016, 12:39:25 PM8/22/16
to Cukes
Charles Radley wrote:


Hi Paolo,


On 8/22/2016 2:58 AM, Paolo Ambrosio wrote:

From Paolo:


You might want to take a look at the official example that is much simpler: https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng
 


Hope you have a build system (Maven, Gradle, ...) to verify that the code you wrote runs correctly before trying the IDE integration. Or you can try and run an existing working example in the IDE, like the Java Calculator TestNG above.


I use Maven.

I can run the example successfully at the command line, see transcript below.

How do I now run this in the Eclispe IDE ?

Björn Rasmusson

unread,
Aug 22, 2016, 12:44:19 PM8/22/16
to Cukes
Charles Radley wrote:

Hi Paolo and co,

On 8/22/2016 2:58 AM, Paolo Ambrosio wrote:

From Paolo:

> > You might want to take a look at the official example that is much > simpler: > https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng > > >

The example project above does not include any testng.xml file.....

Does that mean I do not need a testng.xml  file in my cucumber testng projects ?

Is the testng.xml required ?  Is it optional?  Has it been recently deprecated ?

Should I ignore the various blog posts which talk about using a testng.xml file with cucumber ?


testng.xml belongs to the TestNG realm, not to the Cucumber-JVM realm. In a project with several runner classes for TestNG, testng.xml could select which of those to execute, but it cannot affect what Cucumber-JVM does when it has been started by the runner class. That is controlled by @CucumberOptions annotation or the -Dcucumber.options setting.

Björn

 

Charles Radley

unread,
Aug 22, 2016, 1:24:35 PM8/22/16
to cu...@googlegroups.com

Thank you Björn, your explanation is very clear.


On 8/22/2016 12:44 PM, Björn Rasmusson wrote:
>
> testng.xml belongs to the TestNG realm, not to the Cucumber-JVM realm.
> In a project with several runner classes for TestNG, testng.xml could
> select which of those to execute, but it cannot affect what
> Cucumber-JVM does when it has been started by the runner class. That
> is controlled by @CucumberOptions annotation or the -Dcucumber.options
> setting.
>
> Björn


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Charles Radley

unread,
Aug 22, 2016, 2:15:28 PM8/22/16
to cu...@googlegroups.com



On 8/22/2016 12:39 PM, Björn Rasmusson wrote:
Charles Radley wrote:


Hi Paolo,


On 8/22/2016 2:58 AM, Paolo Ambrosio wrote:

From Paolo:


You might want to take a look at the official example that is much simpler: https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng
 
I use Maven.

I can run the example successfully at the command line, see transcript below.

How do I now run this in the Eclispe IDE ?

Alas that does not work .... the "Run As" list is empty when I right click on each of those objects.... and I am unable to set up a new "Run configuration", since Eclipse insists that the "Cucmber-jvm project does not exist" .... even though it is clearly visible in eclipse with my eyeball ....

Am I the only person on this list who uses eclipse ?

I really need some advice here.   Running in maven only is not viable for code development.

What IDE do you use ?  Maybe I should switch.....

George Dinwiddie

unread,
Aug 22, 2016, 2:33:31 PM8/22/16
to cu...@googlegroups.com
Charles,

On 8/22/16 2:15 PM, Charles Radley wrote:
> Am I the only person on this list who uses eclipse ?

Certainly not the only one using Eclipse, but perhaps the only one
trying to use TestNG under Eclipse. I tried that years ago (without
Cucumber in the mix), and had trouble. I didn't get much help from the
TestNG list, but perhaps you can find some help there now.

- George

--
----------------------------------------------------------------------
* George Dinwiddie * http://blog.gdinwiddie.com
Software Development http://www.idiacomputing.com
Consultant and Coach http://www.agilemaryland.org
----------------------------------------------------------------------

Charles Radley

unread,
Aug 22, 2016, 2:35:52 PM8/22/16
to cu...@googlegroups.com

Thanks George.

My colleagues [at two different companies] and I have been fairly
successful using TestNG within Eclipse.

Adding cucumber to the mix seems problematic.

Best,

CFR.


On 8/22/2016 2:33 PM, George Dinwiddie wrote:
> Charles,
>
> On 8/22/16 2:15 PM, Charles Radley wrote:
>> Am I the only person on this list who uses eclipse ?
>
> Certainly not the only one using Eclipse, but perhaps the only one
> trying to use TestNG under Eclipse. I tried that years ago (without
> Cucumber in the mix), and had trouble. I didn't get much help from the
> TestNG list, but perhaps you can find some help there now.
>
> - George
>

--
Best regards,

Charles Radley - Associate Fellow AIAA

Ooma phone: +1-503-922-1012
cell phone: +1-360-773-2595 - cell
Skype: CFRJLR


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Paolo Ambrosio

unread,
Aug 23, 2016, 2:32:27 AM8/23/16
to cu...@googlegroups.com
On Mon, Aug 22, 2016 at 7:35 PM, Charles Radley <cfr...@gmail.com> wrote:
>
> Thanks George.
>
> My colleagues [at two different companies] and I have been fairly successful
> using TestNG within Eclipse.
>
> Adding cucumber to the mix seems problematic.

I've installed Eclipse 4.6.0, TestNG plugin 6.9.12 and imported the
Maven project java-calculator-testng (removing the -SNAPSHOT version
of the parent pom). Right clicked on RunCukesTest.java and selected
"Run As" -> "TestNG Test" and all features ran.

Then the menu disappeared. Good old unpredictable Eclipse!

If I add "@Test public void empty() {}" to RunCukesTest I can see the
menu again, so that makes me think that the Eclipse TestNG plugin
doesn't look for the @Test annotation in the parent
AbstractTestNGCucumberTests class. Not sure how it worked the first
time.

Adding a TestNG configuration ("Run As" -> "Run Configurations..." /
"TestNG") for the class works, so you should be OK.

> Best,
>
> CFR.
>
>
> On 8/22/2016 2:33 PM, George Dinwiddie wrote:
>>
>> Charles,
>>
>> On 8/22/16 2:15 PM, Charles Radley wrote:
>>>
>>> Am I the only person on this list who uses eclipse ?
>>
>>
>> Certainly not the only one using Eclipse, but perhaps the only one trying
>> to use TestNG under Eclipse. I tried that years ago (without Cucumber in the
>> mix), and had trouble. I didn't get much help from the TestNG list, but
>> perhaps you can find some help there now.
>>
>> - George
>>
>
> --
> Best regards,
>
> Charles Radley - Associate Fellow AIAA
>
> Ooma phone: +1-503-922-1012
> cell phone: +1-360-773-2595 - cell
> Skype: CFRJLR
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
>
> --
> Posting rules: http://cukes.info/posting-rules.html
> --- You received this message because you are subscribed to the Google
> Groups "Cukes" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cukes+un...@googlegroups.com.

Charles Radley

unread,
Aug 23, 2016, 8:11:40 AM8/23/16
to cu...@googlegroups.com

Thanks Paolo, I will give it a shot !


On 8/23/2016 2:32 AM, Paolo Ambrosio wrote:
> I've installed Eclipse 4.6.0, TestNG plugin 6.9.12 and imported the
> Maven project java-calculator-testng (removing the -SNAPSHOT version
> of the parent pom). Right clicked on RunCukesTest.java and selected
> "Run As" -> "TestNG Test" and all features ran.
>
> Then the menu disappeared. Good old unpredictable Eclipse!
>
> If I add "@Test public void empty() {}" to RunCukesTest I can see the
> menu again, so that makes me think that the Eclipse TestNG plugin
> doesn't look for the @Test annotation in the parent
> AbstractTestNGCucumberTests class. Not sure how it worked the first
> time.
>
> Adding a TestNG configuration ("Run As" -> "Run Configurations..." /
> "TestNG") for the class works, so you should be OK.


Reply all
Reply to author
Forward
0 new messages