With the addition
of my jersey client tests, I thought I was
ready to add cucumber support to my project.
I was wrong.
The documentation on using Cucumber and TestNG is a bit sparse
and I was getting a bit flustered on where to put the feature definition file.
It turns out that I was making a mountain out of a mole hill.
If you put the feature file in the wrong place,
then cucumber will tell you where it was looking.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
$ mvn clean test -q -Dskip=client,browser
------------------------------------------------------- T E S T S ------------------------------------------------------- Running TestSuite Configuring TestNG with: TestNG652Configurator No features found at [classpath:com/ideoplex/tutorial]
0 Scenarios 0 Steps 0m0.000s
Tests run:4, Failures:0, Errors:0, Skipped:0, Time elapsed:1.806 sec - in TestSuite
Results :
Tests run:4, Failures:0, Errors:0, Skipped:0
So here’s the CucumberTest implementation of AbstractTestNGCucumberTests that
does the work.
Here’s the feature file,
placed in src/test/resources/com/ideoplex/tutorial
to match the package path of CucumberTest.
1 2 3 4 5 6 7 8 9 10 11 12 13
Feature: User Management
Scenario: Add New Email Given prospective user with email "user@example.com" pre-exists And email "user@example.com"isnot pre-registered When user submits add "user@example.com" form Then email "user@example.com"is registered
Scenario: Reject Duplicate Email Given prospective user with email "user@example.com" pre-exists And email "user@example.com"is pre-registered When user submits add "user@example.com" form Then duplicate email "user@example.com"erroris thrown
And the updates to the pom.xml to include the cucumber dependencies.