victorolinasc / junit-formatter

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

Not working for failing tests on 1.2.0-rc.1 #6

Closed chrismcg closed 8 years ago

chrismcg commented 8 years ago

Just trying your library out on a 1.2.0-rc.1 app on CircleCI. Works great when there's no failures but if there is a failure then I get a FunctionClauseError

19:13:55.292 [error] GenEvent handler JUnitFormatter installed in #PID<0.529.0> terminating
** (FunctionClauseError) no function clause matching in JUnitFormatter.generate_test_body/1
    lib/formatter.ex:154: JUnitFormatter.generate_test_body(%ExUnit.Test{case: Ostali.UserTest, logs: "", name: :"test changeset with valid attributes", state: {:failed, [{:error, %ExUnit.AssertionError{expr: {{:., [line: 18], [{:changeset, [line: 18], nil}, :valid?]}, [line: 18], []}, left: :ex_unit_no_meaningful_value, message: "Expected false or nil, got true", right: :ex_unit_no_meaningful_value}, [{Ostali.UserTest, :"test changeset with valid attributes", 1, [file: 'test/models/user_test.exs', line: 18]}]}]}, tags: %{async: false, case: Ostali.UserTest, file: "/Users/chris/dev/apps/ostali/test/models/user_test.exs", line: 16, test: :"test changeset with valid attributes"}, time: 3378})
    lib/formatter.ex:150: JUnitFormatter.generate_testcases/1
    lib/formatter.ex:140: anonymous fn/2 in JUnitFormatter.generate_testsuite_xml/1
    (elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/formatter.ex:139: JUnitFormatter.generate_testsuite_xml/1
    (elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1088: Enum."-map/2-lists^map/1-0-"/2
    lib/formatter.ex:66: JUnitFormatter.handle_event/2
    (stdlib) gen_event.erl:538: :gen_event.server_update/4
    (stdlib) gen_event.erl:520: :gen_event.server_notify/4
    (stdlib) gen_event.erl:261: :gen_event.handle_msg/5
    (stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

I think this might be related to the 1.2 changelog entry:

[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

I don't have time to dig into this myself an provide a patch at the moment unfortunately.

cs-victor-nascimento commented 8 years ago

Thanks for reporting this one!

I still haven't got the time to test it on 1.2. I need to set up some Docker image in order not to mess with my current installation.

As soon as I can I will take a look at it. Thanks once again.