-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented TestNG-compatible XML formatter. #621
Conversation
It's a great point to start. |
@deadmoto I would like to discuss the not using CucumberRuntime in the test. Of course I am biased since I was the one that extracted out the support for testing formatters using the CucumberRuntime to TestHelper. I would appreciate any feedback that help make these methods more obvious and easy to use for other developers. One draw black of not using the CucumberRuntime when testing the formatters is that they might stop working without you noticing it. It is not as far fetched as it sound, in v1.1.3 the PrettyFormatter stopped working and threw a IndexOutOfBoundsException (since the PrettyFormatter is part of the Gherkin library, the tests there cannot verify that the formatter actually will work when executed in Cucumber-JVM, which is an extra complication in that case). Personally I really the explicitness of a test like JUnitFormatterTest.should_format_passed_scenario, the structure like "Given this feature, and some information about what steps passes, fails, and so on, then the formatter should produce this output". The formatter output is right there, and not in another file, which must be inspected to see the expected output (it is however a little annoying with all the '"' in the expected xml output). WDYT? |
@brasmusson, sorry for such long delay. As for me, there is no difference between invoking formatter directly or through CucumberRuntime. |
@deadmoto The extra control from calling the formatter directly comes with a cost. The Did you consider to expected result data in the test cases? To me, reading |
@brasmusson I used JUnitFormatter as a base but implemented it after |
@deadmoto I used one of the very few changes in the formatter interface, to make the point overly clear. It was a bit unnecessary of me, I am confident that you see the pros and cons just as clear as I do. I do not say that you absolutely need to change the direct calls to formatter and use TestHelper instead, given the exception class name extraction in TestNGFormatter, that would need some work in TestHelper to support that (and BTW, it is good you used the I do think you should have a look at for instance JUnitFormatterTest.should_format_passed_scenario, and see if you think it would be an improvement to have the expected formatter output right there in the test case, instead of in a separate file. When you used the JUnitFormatter as a base you got some handling of scenario outlines that is not really working well from the JUnitFormatter (I have just realized). Extract from the expected data for testScenarioOutlineWithExamples:
To me it looks like a simple solution for making the name attributes unique, start at the number of example row and count down. First it feels a bit unnatural to count down instead of count up. Secondly a scenario outline can have several set of examples (several example tables) and in that case you would get |
I was on vacation these two weeks, so I had to spent some time reading this thread, looking into the code and rethinking it. I took a look over JUnitFormatterTest.should_format_passed_scenario and I found it very convenient. What for scenario outlines and certain executions names, the only proper way to prevent scenario name duplication and to keep their natural order is to put names of the scenarios being executed and the number of executions into some kind of Map<String, Integer>. WDYT? |
Yes, using When using scenario outlines to test the Rerun formatter, the fact that the different examples had different result was handled through that the resulting step string after expanding the parameterized steps are different and can be mapped to different results. I do not know how often it actually will be necessary to have the exact same step give different results i a single test case. Maybe a simple map from steps to result should be kept until the need arises in actual test cases. |
It's a shame, I forgot about this issue! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Once again :)
Hi there!
This class produces TestNG-compatible XML report, including date\time, duration and stacktraces if possible.
I used JUnitFormatter as an example with some modifications and simplifications.
All tests call formatter directly without using CucumberRuntime.
What about wrapping Exceptions with Mockito, latter does not allow wraping of getClass method so I had to use the real Exception object...