victorolinasc / junit-formatter

A JUnit XML report exporter for Elixir's ExUnit
https://hexdocs.pm/junit_formatter/
Apache License 2.0
111 stars 37 forks source link

Fix library for failed test on elixir 1.2.0 #7

Closed adrienmo closed 8 years ago

adrienmo commented 8 years ago

Fix #6

For some reason, %ExUnit.state format we received in the function generate_test_body is not correct. We get something like {:failed, [failed]} instead of `{:failed, failed}

I added a new clause for generate_test_body taking care of this new format. I am not entirely sure of the root cause of this problem, but this fix will solve it.

andruby commented 8 years ago

@adrienmo I think this is the new behavior in Elixir 1.2.0:

[ExUnit] Allow one test to raise multiple errors. The goal is to enable tools in the ecosystem to emit multiple failure reports from the same test

We should probably support multiple failures instead of ignoring all but the first one

adrienmo commented 8 years ago

@andruby This is indeed something introduce in elixir 1.2.0:

https://github.com/elixir-lang/elixir/blob/v1.2.0/lib/ex_unit/lib/ex_unit/runner.ex#L353

But I think in most case, only one element will be present in the array. Multiple element will be present if the user specifically raise several errors:

raise ExUnit.MultiError, errors: [error1, error2]

I am not sure how and if it is really useful to merge the different error into one message errors for the test case ?

victorolinasc commented 8 years ago

I agree with @adrienmo that we should support all failures from a test. I will merge this one for now because it fixes #6.

Do you guys think that several failure nodes will break Jenkins or other tools that read this XML? I know that in Java you can only have one failed assertion per test but several failure nodes is also valid XML.

@adrienmo @andruby what do you guys think?