cargo2junit icon indicating copy to clipboard operation
cargo2junit copied to clipboard

Also report file names

Open svenstaro opened this issue 4 years ago • 3 comments

It would be neat if this tool could also extract the filenames of the thing that's being tested (in the case of integration tests). For example:

     Running unittests (target/debug/deps/generate_openapi_spec-e3bc6e08330e8181)
{ "type": "suite", "event": "started", "test_count": 0 }
{ "type": "suite", "event": "ok", "passed": 0, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.000019477 }
     Running tests/test_api_openapi.rs (target/debug/deps/test_api_openapi-53c722415f8c53df)
{ "type": "suite", "event": "started", "test_count": 1 }
{ "type": "test", "event": "started", "name": "read::can_read" }
{ "type": "test", "name": "read::can_read", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 1, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.06092743 }

As we can see, we can extract the filenames from that text. These would then end up in <testcase file=tests/test_api_openapi.rs/> which I think would be quite neat. GitLab can actually display those: https://gitlab.com/gitlab-org/gitlab/-/issues/119032

svenstaro avatar Apr 30 '21 04:04 svenstaro

@svenstaro does that work when using --test-threads?

kristof-mattei avatar Feb 03 '22 21:02 kristof-mattei

Hm good question and I actually don't know.

svenstaro avatar Feb 04 '22 04:02 svenstaro

I was looking into the source code of cargo test to see if we can extend the json format one way or another to include this on the line itself, removing all ambiguity.

kristof-mattei avatar Feb 04 '22 15:02 kristof-mattei