|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- Feature: JUnit output formatter
- In order for developers to create test reports with ant
- Cucumber should be able to output JUnit xml files
-
- Background:
- Given the standard step definitions
- And a file named "features/one_passing_one_failing.feature" with:
- """
- Feature: One passing scenario, one failing scenario
-
- Scenario: Passing
- Given this step passes
-
- Scenario: Failing
- Given this step fails
- """
- And a file named "features/some_subdirectory/one_passing_one_failing.feature" with:
- """
- Feature: Subdirectory - One passing scenario, one failing scenario
-
- Scenario: Passing
- Given this step passes
-
- Scenario: Failing
- Given this step fails
- """
- And a file named "features/pending.feature" with:
- """
- Feature: Pending step
-
- Scenario: Pending
- Given this step is pending
-
- Scenario: Undefined
- Given this step is undefined
- """
- And a file named "features/pending.feature" with:
- """
- Feature: Pending step
-
- Scenario: Pending
- Given this step is pending
-
- Scenario: Undefined
- Given this step is undefined
- """
- And a file named "features/scenario_outline.feature" with:
- """
- Feature: Scenario outlines
-
- Scenario Outline: Using scenario outlines
- Given this step <type>
-
- Examples:
- | type |
- | passes |
- | fails |
- | is pending |
- | is undefined |
- """
- And a file named "features/encoding_output.feature" with:
- """
- Feature: One passing scenario, one failing scenario
-
- Scenario: Passing
- Given a passing ctrl scenario
- """
- And a file named "features/step_definitions/junit_steps.rb" with:
- """
- Given /^Given a passing ctrl scenario/ do
- Kernel.puts "encoding"
- Kernel.puts "pickle".encode("UTF-16")
- end
- """
-
- Scenario: one feature, one passing scenario, one failing scenario
- When I run `cucumber --format junit --out tmp/ features/one_passing_one_failing.feature`
- Then it should fail with:
- """
-
- """
- And the junit output file "tmp/TEST-features-one_passing_one_failing.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="One passing scenario, one failing scenario">
- <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.05">
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.05">
- <failure message="failed Failing" type="failed">
- <![CDATA[Scenario: Failing
-
- Given this step fails
-
- Message:
- ]]>
- <![CDATA[ (RuntimeError)
- ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
- features/one_passing_one_failing.feature:7:in `this step fails']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: one feature, one passing scenario, one failing scenario, add file attribute
- When I run `cucumber --format junit,fileattribute=true --out tmp/ features/one_passing_one_failing.feature`
- Then it should fail with:
- """
-
- """
- And the junit output file "tmp/TEST-features-one_passing_one_failing.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="One passing scenario, one failing scenario">
- <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.05" file="features/one_passing_one_failing.feature">
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.05" file="features/one_passing_one_failing.feature">
- <failure message="failed Failing" type="failed">
- <![CDATA[Scenario: Failing
-
- Given this step fails
-
- Message:
- ]]>
- <![CDATA[ (RuntimeError)
- ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
- features/one_passing_one_failing.feature:7:in `this step fails']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: one feature in a subdirectory, one passing scenario, one failing scenario
- When I run `cucumber --format junit --out tmp/ features/some_subdirectory/one_passing_one_failing.feature --require features`
- Then it should fail with:
- """
-
- """
- And the junit output file "tmp/TEST-features-some_subdirectory-one_passing_one_failing.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="Subdirectory - One passing scenario, one failing scenario">
- <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Passing" time="0.05">
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Failing" time="0.05">
- <failure message="failed Failing" type="failed">
- <![CDATA[Scenario: Failing
-
- Given this step fails
-
- Message:
- ]]>
- <![CDATA[ (RuntimeError)
- ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
- features/some_subdirectory/one_passing_one_failing.feature:7:in `this step fails']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: pending and undefined steps are reported as skipped
- When I run `cucumber --format junit --out tmp/ features/pending.feature`
- Then it should pass with:
- """
-
- """
- And the junit output file "tmp/TEST-features-pending.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="0" errors="0" skipped="2" tests="2" time="0.05" name="Pending step">
- <testcase classname="Pending step" name="Pending" time="0.05">
- <skipped/>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Pending step" name="Undefined" time="0.05">
- <skipped/>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: pending and undefined steps add fileattribute
- When I run `cucumber --format junit,fileattribute=true --out tmp/ features/pending.feature`
- Then it should pass with:
- """
-
- """
- And the junit output file "tmp/TEST-features-pending.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="0" errors="0" skipped="2" tests="2" time="0.05" name="Pending step">
- <testcase classname="Pending step" name="Pending" time="0.05" file="features/pending.feature">
- <skipped/>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Pending step" name="Undefined" time="0.05" file="features/pending.feature">
- <skipped/>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: pending and undefined steps with strict option should fail
- When I run `cucumber --format junit --out tmp/ features/pending.feature --strict`
- Then it should fail with:
- """
-
- """
- And the junit output file "tmp/TEST-features-pending.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="2" errors="0" skipped="0" tests="2" time="0.05" name="Pending step">
- <testcase classname="Pending step" name="Pending" time="0.05">
- <failure message="pending Pending" type="pending">
- <![CDATA[Scenario: Pending
-
- Given this step is pending
-
- Message:
- ]]>
- <![CDATA[TODO (Cucumber::Pending)
- ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
- features/pending.feature:4:in `this step is pending']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Pending step" name="Undefined" time="0.05">
- <failure message="undefined Undefined" type="undefined">
- <![CDATA[Scenario: Undefined
-
- Given this step is undefined
-
- Message:
- ]]>
- <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
- features/pending.feature:7:in `this step is undefined']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: run all features
- When I run `cucumber --format junit --out tmp/ features`
- Then it should fail with:
- """
-
- """
- And a file named "tmp/TEST-features-one_passing_one_failing.xml" should exist
- And a file named "tmp/TEST-features-pending.xml" should exist
-
- Scenario: show correct error message if no --out is passed
- When I run `cucumber --format junit features`
- Then the stderr should not contain:
- """
- can't convert .* into String \(TypeError\)
- """
- And the stderr should contain:
- """
- You *must* specify --out DIR for the junit formatter
- """
-
- Scenario: strict mode, one feature, one scenario outline, four examples: one passing, one failing, one pending, one undefined
- When I run `cucumber --strict --format junit --out tmp/ features/scenario_outline.feature`
- Then it should fail with:
- """
-
- """
- And the junit output file "tmp/TEST-features-scenario_outline.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="3" errors="0" skipped="0" tests="4" time="0.05" name="Scenario outlines">
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passes |)" time="0.05">
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | fails |)" time="0.05">
- <failure message="failed Using scenario outlines (outline example : | fails |)" type="failed">
- <![CDATA[Scenario Outline: Using scenario outlines
-
- Example row: | fails |
-
- Message:
- ]]>
- <![CDATA[ (RuntimeError)
- ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
- features/scenario_outline.feature:9:4:in `this step fails']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is pending |)" time="0.05">
- <failure message="pending Using scenario outlines (outline example : | is pending |)" type="pending">
- <![CDATA[Scenario Outline: Using scenario outlines
-
- Example row: | is pending |
-
- Message:
- ]]>
- <![CDATA[TODO (Cucumber::Pending)
- ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
- features/scenario_outline.feature:10:4:in `this step is pending']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is undefined |)" time="0.05">
- <failure message="undefined Using scenario outlines (outline example : | is undefined |)" type="undefined">
- <![CDATA[Scenario Outline: Using scenario outlines
-
- Example row: | is undefined |
-
- Message:
- ]]>
- <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
- features/scenario_outline.feature:11:4:in `this step is undefined']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: strict mode with --expand option, one feature, one scenario outline, four examples: one passing, one failing, one pending, one undefined
- When I run `cucumber --strict --expand --format junit --out tmp/ features/scenario_outline.feature --publish-quiet`
- Then it should fail with exactly:
- """
-
- """
- And the junit output file "tmp/TEST-features-scenario_outline.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="3" errors="0" skipped="0" tests="4" time="0.05" name="Scenario outlines">
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passes |)" time="0.05">
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | fails |)" time="0.05">
- <failure message="failed Using scenario outlines (outline example : | fails |)" type="failed">
- <![CDATA[Scenario Outline: Using scenario outlines
-
- Example row: | fails |
-
- Message:
- ]]>
- <![CDATA[ (RuntimeError)
- ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
- features/scenario_outline.feature:9:4:in `this step fails']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is pending |)" time="0.05">
- <failure message="pending Using scenario outlines (outline example : | is pending |)" type="pending">
- <![CDATA[Scenario Outline: Using scenario outlines
-
- Example row: | is pending |
-
- Message:
- ]]>
- <![CDATA[TODO (Cucumber::Pending)
- ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
- features/scenario_outline.feature:10:4:in `this step is pending']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is undefined |)" time="0.05">
- <failure message="undefined Using scenario outlines (outline example : | is undefined |)" type="undefined">
- <![CDATA[Scenario Outline: Using scenario outlines
-
- Example row: | is undefined |
-
- Message:
- ]]>
- <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
- features/scenario_outline.feature:11:4:in `this step is undefined']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
-
- Scenario: run test cases from different features interweaved
- When I run `cucumber --format junit --out tmp/ features/one_passing_one_failing.feature:3 features/pending.feature:3 features/one_passing_one_failing.feature:6`
- Then it should fail with:
- """
-
- """
- And the junit output file "tmp/TEST-features-one_passing_one_failing.xml" should contain:
- """
- <?xml version="1.0" encoding="UTF-8"?>
- <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="One passing scenario, one failing scenario">
- <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.05">
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.05">
- <failure message="failed Failing" type="failed">
- <![CDATA[Scenario: Failing
-
- Given this step fails
-
- Message:
- ]]>
- <![CDATA[ (RuntimeError)
- ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
- features/one_passing_one_failing.feature:7:in `this step fails']]>
- </failure>
- <system-out>
- <![CDATA[]]>
- </system-out>
- <system-err>
- <![CDATA[]]>
- </system-err>
- </testcase>
- </testsuite>
-
- """
- And a file named "tmp/TEST-features-pending.xml" should exist
-
- @wip-jruby
- Scenario: mixed encoding outputs are handled across all supported ruby versions, failing on jruby currently
- When I run `cucumber --format junit --out tmp/ features/encoding_output.feature`
- Then it should pass
|