Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test with undefined steps not flagged as a failed test

I am facing the issue of a test that has undefined step(s) not being flagged as a failed test.

In the Java code we use Selenium 2/WebDriver and tests are driven by Ant and run in a Continuous Integration environment.

For the following scenario:

@test1

Scenario: Run test with an undefined step

Given I am logged in to the application //working

And I view the test example //working

Then the tree panel exists in the layout //undefined step

The following is a snippet of what is seen in the console:

@test1

Scenario: Run test with an undefined step

Given I am logged in to the application

And I view the test example

Then the tree panel exists in the layout

1 scenario (1 undefined)

3 steps (1 undefined, 2 passed)

The ant target used to run the test:

ant test.cuke.firefox -Dwebtest.server="http://localhost:9944" -Dwebtest.cuke.options="--tags @test1"|wac

I read that using the --strict flag gets the tests to fail. But I've no idea of where I need to mention the flag.

  1. Is it in the build.xml file? If so, where exactly - as wherever I've tried hasn't helped.

  2. Is it in the cucumber.yml file?

There are 2 such files:

i) \lib\cucumber.jruby\gems\cucumber-0.8.7

ii) \lib\cucumber.jruby\gems\gherkin-2.1.5-java

If not in these files, where else?

Could you please point to where and how the flag needs to be set? I've tried looking up the help but nothing has helped (probably I'm looking in all the wrong places!)

Thanks!

like image 312
Mia Avatar asked Nov 18 '25 00:11

Mia


1 Answers

You need to set the strict option:

http://cukes.info/api/cucumber/jvm/javadoc/cucumber/api/junit/Cucumber.Options.html#strict()

Edit: You can set this flag in the RunCukesTest like:

@RunWith(Cucumber.class)
@Cucumber.Options(
  format = {"html:target/cucumber-html-report"}, 
  strict = true)
public class RunCukesTest {
}
like image 102
core Avatar answered Nov 19 '25 14:11

core