You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

junit_formatter.feature 18 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. Feature: JUnit output formatter
  2. In order for developers to create test reports with ant
  3. Cucumber should be able to output JUnit xml files
  4. Background:
  5. Given the standard step definitions
  6. And a file named "features/one_passing_one_failing.feature" with:
  7. """
  8. Feature: One passing scenario, one failing scenario
  9. Scenario: Passing
  10. Given this step passes
  11. Scenario: Failing
  12. Given this step fails
  13. """
  14. And a file named "features/some_subdirectory/one_passing_one_failing.feature" with:
  15. """
  16. Feature: Subdirectory - One passing scenario, one failing scenario
  17. Scenario: Passing
  18. Given this step passes
  19. Scenario: Failing
  20. Given this step fails
  21. """
  22. And a file named "features/pending.feature" with:
  23. """
  24. Feature: Pending step
  25. Scenario: Pending
  26. Given this step is pending
  27. Scenario: Undefined
  28. Given this step is undefined
  29. """
  30. And a file named "features/pending.feature" with:
  31. """
  32. Feature: Pending step
  33. Scenario: Pending
  34. Given this step is pending
  35. Scenario: Undefined
  36. Given this step is undefined
  37. """
  38. And a file named "features/scenario_outline.feature" with:
  39. """
  40. Feature: Scenario outlines
  41. Scenario Outline: Using scenario outlines
  42. Given this step <type>
  43. Examples:
  44. | type |
  45. | passes |
  46. | fails |
  47. | is pending |
  48. | is undefined |
  49. """
  50. And a file named "features/encoding_output.feature" with:
  51. """
  52. Feature: One passing scenario, one failing scenario
  53. Scenario: Passing
  54. Given a passing ctrl scenario
  55. """
  56. And a file named "features/step_definitions/junit_steps.rb" with:
  57. """
  58. Given /^Given a passing ctrl scenario/ do
  59. Kernel.puts "encoding"
  60. Kernel.puts "pickle".encode("UTF-16")
  61. end
  62. """
  63. Scenario: one feature, one passing scenario, one failing scenario
  64. When I run `cucumber --format junit --out tmp/ features/one_passing_one_failing.feature`
  65. Then it should fail with:
  66. """
  67. """
  68. And the junit output file "tmp/TEST-features-one_passing_one_failing.xml" should contain:
  69. """
  70. <?xml version="1.0" encoding="UTF-8"?>
  71. <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="One passing scenario, one failing scenario">
  72. <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.05">
  73. <system-out>
  74. <![CDATA[]]>
  75. </system-out>
  76. <system-err>
  77. <![CDATA[]]>
  78. </system-err>
  79. </testcase>
  80. <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.05">
  81. <failure message="failed Failing" type="failed">
  82. <![CDATA[Scenario: Failing
  83. Given this step fails
  84. Message:
  85. ]]>
  86. <![CDATA[ (RuntimeError)
  87. ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
  88. features/one_passing_one_failing.feature:7:in `this step fails']]>
  89. </failure>
  90. <system-out>
  91. <![CDATA[]]>
  92. </system-out>
  93. <system-err>
  94. <![CDATA[]]>
  95. </system-err>
  96. </testcase>
  97. </testsuite>
  98. """
  99. Scenario: one feature, one passing scenario, one failing scenario, add file attribute
  100. When I run `cucumber --format junit,fileattribute=true --out tmp/ features/one_passing_one_failing.feature`
  101. Then it should fail with:
  102. """
  103. """
  104. And the junit output file "tmp/TEST-features-one_passing_one_failing.xml" should contain:
  105. """
  106. <?xml version="1.0" encoding="UTF-8"?>
  107. <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="One passing scenario, one failing scenario">
  108. <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.05" file="features/one_passing_one_failing.feature">
  109. <system-out>
  110. <![CDATA[]]>
  111. </system-out>
  112. <system-err>
  113. <![CDATA[]]>
  114. </system-err>
  115. </testcase>
  116. <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.05" file="features/one_passing_one_failing.feature">
  117. <failure message="failed Failing" type="failed">
  118. <![CDATA[Scenario: Failing
  119. Given this step fails
  120. Message:
  121. ]]>
  122. <![CDATA[ (RuntimeError)
  123. ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
  124. features/one_passing_one_failing.feature:7:in `this step fails']]>
  125. </failure>
  126. <system-out>
  127. <![CDATA[]]>
  128. </system-out>
  129. <system-err>
  130. <![CDATA[]]>
  131. </system-err>
  132. </testcase>
  133. </testsuite>
  134. """
  135. Scenario: one feature in a subdirectory, one passing scenario, one failing scenario
  136. When I run `cucumber --format junit --out tmp/ features/some_subdirectory/one_passing_one_failing.feature --require features`
  137. Then it should fail with:
  138. """
  139. """
  140. And the junit output file "tmp/TEST-features-some_subdirectory-one_passing_one_failing.xml" should contain:
  141. """
  142. <?xml version="1.0" encoding="UTF-8"?>
  143. <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="Subdirectory - One passing scenario, one failing scenario">
  144. <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Passing" time="0.05">
  145. <system-out>
  146. <![CDATA[]]>
  147. </system-out>
  148. <system-err>
  149. <![CDATA[]]>
  150. </system-err>
  151. </testcase>
  152. <testcase classname="Subdirectory - One passing scenario, one failing scenario" name="Failing" time="0.05">
  153. <failure message="failed Failing" type="failed">
  154. <![CDATA[Scenario: Failing
  155. Given this step fails
  156. Message:
  157. ]]>
  158. <![CDATA[ (RuntimeError)
  159. ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
  160. features/some_subdirectory/one_passing_one_failing.feature:7:in `this step fails']]>
  161. </failure>
  162. <system-out>
  163. <![CDATA[]]>
  164. </system-out>
  165. <system-err>
  166. <![CDATA[]]>
  167. </system-err>
  168. </testcase>
  169. </testsuite>
  170. """
  171. Scenario: pending and undefined steps are reported as skipped
  172. When I run `cucumber --format junit --out tmp/ features/pending.feature`
  173. Then it should pass with:
  174. """
  175. """
  176. And the junit output file "tmp/TEST-features-pending.xml" should contain:
  177. """
  178. <?xml version="1.0" encoding="UTF-8"?>
  179. <testsuite failures="0" errors="0" skipped="2" tests="2" time="0.05" name="Pending step">
  180. <testcase classname="Pending step" name="Pending" time="0.05">
  181. <skipped/>
  182. <system-out>
  183. <![CDATA[]]>
  184. </system-out>
  185. <system-err>
  186. <![CDATA[]]>
  187. </system-err>
  188. </testcase>
  189. <testcase classname="Pending step" name="Undefined" time="0.05">
  190. <skipped/>
  191. <system-out>
  192. <![CDATA[]]>
  193. </system-out>
  194. <system-err>
  195. <![CDATA[]]>
  196. </system-err>
  197. </testcase>
  198. </testsuite>
  199. """
  200. Scenario: pending and undefined steps add fileattribute
  201. When I run `cucumber --format junit,fileattribute=true --out tmp/ features/pending.feature`
  202. Then it should pass with:
  203. """
  204. """
  205. And the junit output file "tmp/TEST-features-pending.xml" should contain:
  206. """
  207. <?xml version="1.0" encoding="UTF-8"?>
  208. <testsuite failures="0" errors="0" skipped="2" tests="2" time="0.05" name="Pending step">
  209. <testcase classname="Pending step" name="Pending" time="0.05" file="features/pending.feature">
  210. <skipped/>
  211. <system-out>
  212. <![CDATA[]]>
  213. </system-out>
  214. <system-err>
  215. <![CDATA[]]>
  216. </system-err>
  217. </testcase>
  218. <testcase classname="Pending step" name="Undefined" time="0.05" file="features/pending.feature">
  219. <skipped/>
  220. <system-out>
  221. <![CDATA[]]>
  222. </system-out>
  223. <system-err>
  224. <![CDATA[]]>
  225. </system-err>
  226. </testcase>
  227. </testsuite>
  228. """
  229. Scenario: pending and undefined steps with strict option should fail
  230. When I run `cucumber --format junit --out tmp/ features/pending.feature --strict`
  231. Then it should fail with:
  232. """
  233. """
  234. And the junit output file "tmp/TEST-features-pending.xml" should contain:
  235. """
  236. <?xml version="1.0" encoding="UTF-8"?>
  237. <testsuite failures="2" errors="0" skipped="0" tests="2" time="0.05" name="Pending step">
  238. <testcase classname="Pending step" name="Pending" time="0.05">
  239. <failure message="pending Pending" type="pending">
  240. <![CDATA[Scenario: Pending
  241. Given this step is pending
  242. Message:
  243. ]]>
  244. <![CDATA[TODO (Cucumber::Pending)
  245. ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
  246. features/pending.feature:4:in `this step is pending']]>
  247. </failure>
  248. <system-out>
  249. <![CDATA[]]>
  250. </system-out>
  251. <system-err>
  252. <![CDATA[]]>
  253. </system-err>
  254. </testcase>
  255. <testcase classname="Pending step" name="Undefined" time="0.05">
  256. <failure message="undefined Undefined" type="undefined">
  257. <![CDATA[Scenario: Undefined
  258. Given this step is undefined
  259. Message:
  260. ]]>
  261. <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
  262. features/pending.feature:7:in `this step is undefined']]>
  263. </failure>
  264. <system-out>
  265. <![CDATA[]]>
  266. </system-out>
  267. <system-err>
  268. <![CDATA[]]>
  269. </system-err>
  270. </testcase>
  271. </testsuite>
  272. """
  273. Scenario: run all features
  274. When I run `cucumber --format junit --out tmp/ features`
  275. Then it should fail with:
  276. """
  277. """
  278. And a file named "tmp/TEST-features-one_passing_one_failing.xml" should exist
  279. And a file named "tmp/TEST-features-pending.xml" should exist
  280. Scenario: show correct error message if no --out is passed
  281. When I run `cucumber --format junit features`
  282. Then the stderr should not contain:
  283. """
  284. can't convert .* into String \(TypeError\)
  285. """
  286. And the stderr should contain:
  287. """
  288. You *must* specify --out DIR for the junit formatter
  289. """
  290. Scenario: strict mode, one feature, one scenario outline, four examples: one passing, one failing, one pending, one undefined
  291. When I run `cucumber --strict --format junit --out tmp/ features/scenario_outline.feature`
  292. Then it should fail with:
  293. """
  294. """
  295. And the junit output file "tmp/TEST-features-scenario_outline.xml" should contain:
  296. """
  297. <?xml version="1.0" encoding="UTF-8"?>
  298. <testsuite failures="3" errors="0" skipped="0" tests="4" time="0.05" name="Scenario outlines">
  299. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passes |)" time="0.05">
  300. <system-out>
  301. <![CDATA[]]>
  302. </system-out>
  303. <system-err>
  304. <![CDATA[]]>
  305. </system-err>
  306. </testcase>
  307. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | fails |)" time="0.05">
  308. <failure message="failed Using scenario outlines (outline example : | fails |)" type="failed">
  309. <![CDATA[Scenario Outline: Using scenario outlines
  310. Example row: | fails |
  311. Message:
  312. ]]>
  313. <![CDATA[ (RuntimeError)
  314. ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
  315. features/scenario_outline.feature:9:4:in `this step fails']]>
  316. </failure>
  317. <system-out>
  318. <![CDATA[]]>
  319. </system-out>
  320. <system-err>
  321. <![CDATA[]]>
  322. </system-err>
  323. </testcase>
  324. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is pending |)" time="0.05">
  325. <failure message="pending Using scenario outlines (outline example : | is pending |)" type="pending">
  326. <![CDATA[Scenario Outline: Using scenario outlines
  327. Example row: | is pending |
  328. Message:
  329. ]]>
  330. <![CDATA[TODO (Cucumber::Pending)
  331. ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
  332. features/scenario_outline.feature:10:4:in `this step is pending']]>
  333. </failure>
  334. <system-out>
  335. <![CDATA[]]>
  336. </system-out>
  337. <system-err>
  338. <![CDATA[]]>
  339. </system-err>
  340. </testcase>
  341. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is undefined |)" time="0.05">
  342. <failure message="undefined Using scenario outlines (outline example : | is undefined |)" type="undefined">
  343. <![CDATA[Scenario Outline: Using scenario outlines
  344. Example row: | is undefined |
  345. Message:
  346. ]]>
  347. <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
  348. features/scenario_outline.feature:11:4:in `this step is undefined']]>
  349. </failure>
  350. <system-out>
  351. <![CDATA[]]>
  352. </system-out>
  353. <system-err>
  354. <![CDATA[]]>
  355. </system-err>
  356. </testcase>
  357. </testsuite>
  358. """
  359. Scenario: strict mode with --expand option, one feature, one scenario outline, four examples: one passing, one failing, one pending, one undefined
  360. When I run `cucumber --strict --expand --format junit --out tmp/ features/scenario_outline.feature --publish-quiet`
  361. Then it should fail with exactly:
  362. """
  363. """
  364. And the junit output file "tmp/TEST-features-scenario_outline.xml" should contain:
  365. """
  366. <?xml version="1.0" encoding="UTF-8"?>
  367. <testsuite failures="3" errors="0" skipped="0" tests="4" time="0.05" name="Scenario outlines">
  368. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | passes |)" time="0.05">
  369. <system-out>
  370. <![CDATA[]]>
  371. </system-out>
  372. <system-err>
  373. <![CDATA[]]>
  374. </system-err>
  375. </testcase>
  376. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | fails |)" time="0.05">
  377. <failure message="failed Using scenario outlines (outline example : | fails |)" type="failed">
  378. <![CDATA[Scenario Outline: Using scenario outlines
  379. Example row: | fails |
  380. Message:
  381. ]]>
  382. <![CDATA[ (RuntimeError)
  383. ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
  384. features/scenario_outline.feature:9:4:in `this step fails']]>
  385. </failure>
  386. <system-out>
  387. <![CDATA[]]>
  388. </system-out>
  389. <system-err>
  390. <![CDATA[]]>
  391. </system-err>
  392. </testcase>
  393. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is pending |)" time="0.05">
  394. <failure message="pending Using scenario outlines (outline example : | is pending |)" type="pending">
  395. <![CDATA[Scenario Outline: Using scenario outlines
  396. Example row: | is pending |
  397. Message:
  398. ]]>
  399. <![CDATA[TODO (Cucumber::Pending)
  400. ./features/step_definitions/steps.rb:3:in `/^this step is pending$/'
  401. features/scenario_outline.feature:10:4:in `this step is pending']]>
  402. </failure>
  403. <system-out>
  404. <![CDATA[]]>
  405. </system-out>
  406. <system-err>
  407. <![CDATA[]]>
  408. </system-err>
  409. </testcase>
  410. <testcase classname="Scenario outlines" name="Using scenario outlines (outline example : | is undefined |)" time="0.05">
  411. <failure message="undefined Using scenario outlines (outline example : | is undefined |)" type="undefined">
  412. <![CDATA[Scenario Outline: Using scenario outlines
  413. Example row: | is undefined |
  414. Message:
  415. ]]>
  416. <![CDATA[Undefined step: "this step is undefined" (Cucumber::Core::Test::Result::Undefined)
  417. features/scenario_outline.feature:11:4:in `this step is undefined']]>
  418. </failure>
  419. <system-out>
  420. <![CDATA[]]>
  421. </system-out>
  422. <system-err>
  423. <![CDATA[]]>
  424. </system-err>
  425. </testcase>
  426. </testsuite>
  427. """
  428. Scenario: run test cases from different features interweaved
  429. 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`
  430. Then it should fail with:
  431. """
  432. """
  433. And the junit output file "tmp/TEST-features-one_passing_one_failing.xml" should contain:
  434. """
  435. <?xml version="1.0" encoding="UTF-8"?>
  436. <testsuite failures="1" errors="0" skipped="0" tests="2" time="0.05" name="One passing scenario, one failing scenario">
  437. <testcase classname="One passing scenario, one failing scenario" name="Passing" time="0.05">
  438. <system-out>
  439. <![CDATA[]]>
  440. </system-out>
  441. <system-err>
  442. <![CDATA[]]>
  443. </system-err>
  444. </testcase>
  445. <testcase classname="One passing scenario, one failing scenario" name="Failing" time="0.05">
  446. <failure message="failed Failing" type="failed">
  447. <![CDATA[Scenario: Failing
  448. Given this step fails
  449. Message:
  450. ]]>
  451. <![CDATA[ (RuntimeError)
  452. ./features/step_definitions/steps.rb:4:in `/^this step fails$/'
  453. features/one_passing_one_failing.feature:7:in `this step fails']]>
  454. </failure>
  455. <system-out>
  456. <![CDATA[]]>
  457. </system-out>
  458. <system-err>
  459. <![CDATA[]]>
  460. </system-err>
  461. </testcase>
  462. </testsuite>
  463. """
  464. And a file named "tmp/TEST-features-pending.xml" should exist
  465. @wip-jruby
  466. Scenario: mixed encoding outputs are handled across all supported ruby versions, failing on jruby currently
  467. When I run `cucumber --format junit --out tmp/ features/encoding_output.feature`
  468. Then it should pass

No Description

Contributors (1)