Closed stefanwatt closed 2 months ago
Hi @stefanwatt,
Could you share a minimal example of the test?
Sure. Should've done that from the start... sorry. Here you go: https://github.com/stefanwatt/drools-test
RuleTest.java is the only test in there.
I could reproduce the issue and found the following:
org.junit.jupiter.api.Test
instead of org.junit.Test
, as shown in the example.org.junit.Test
, test reports are written to .../TEST-junit-vintage.xml
.The solution is to read all three report files and process them. You can patch the following lines: https://github.com/rcasia/neotest-java/blob/d82f3a4aa797c1c62746511a169baf346b49db63/lua/neotest-java/core/result_builder.lua#L81-L96
Are you interested in filing a PR?
Sure. I can give it a shot 👍
Nice! Keep also in mind that spec.context.report_file
is the one that actually is being read, and is set from https://github.com/rcasia/neotest-java/blob/d82f3a4aa797c1c62746511a169baf346b49db63/lua/neotest-java/core/spec_builder.lua#L81 and https://github.com/rcasia/neotest-java/blob/d82f3a4aa797c1c62746511a169baf346b49db63/lua/neotest-java/core/spec_builder.lua#L93
Ok yup. Can confirm that it works when I change the filename in the spec_builder.lua
or switch to junit 5 👍
Is it really necessary to process all three files? Would it not be sufficient to check which package is used and then decide based on that which report file to read?
Admittedly I don't know much about these report files. I read up a bit and it seems that generally you will only care about either TEST-junit-jupiter.xml
or TEST-junit-vintage.xml
but probably not both. Not sure how relevant TEST-junit-platform-suite.xml
is.
It is necessary because I have encountered codebases that use both Jupiter and Vintage engines. This issue may recur when different test classes utilize different engines.
Although the files differ, they share the same format, so this should be transparent to neotest-java.
In this case, it might be more useful if spec.context.report_file
were spec.context.report_dir
instead.
Alright. I'll see what I can come up with.
I pushed something that seems to work. I tested it with junit version 4 and 5. Just wanted to get some feedback before I write/adapt tests.
The test is correctly displayed in the summary panel and the Icon also updates. However when running nearest test I get this message in the output-panel: "This test was not executed."
The test runs fine via
mvn test
and I can debug the test perfectly fine with:Since the output is not particularly helpful I would appreciate any help I can get debugging this.