Comments (4)
Thanks for the issue. I don't really know where people generally use go-junit-report
, so it's great to get feedback like this.
I've had a look at how Gitlab shows JUnit report results and it indeed looks unnecessarily verbose, especially when module names are long. In v1 the classname used to be just the final component of the package path, but I intentionally changed it in v2 to improve how results are shown in Jenkins. From what I remember the classname used to be the full classname (including package), but I see you pointed out the package field so this may have changed. I'm sure there are plenty of other tools that each have their own way of rendering junit reports, so it probably make sense to make this configurable.
I don't think we know exactly which part of the package path is the module root. We could strip the common prefix among all packages as an approximation, but it might not always be correct. Another problem is that the last component in a package path is not always the same as the package name. Looking at the module root of go-junit-report
for example (if it had any tests), we'd get v2
as the classname instead of the expected main
.
I'll have to think a bit about what the best way would be address this and how it could be configured. Any thoughts?
from go-junit-report.
If it's possible to get the module name somehow, then at least in theory it should be safe to trim that as a prefix. If you then end up with an empty string for classname
, we would know we've hit main so you could substitute in the string main
? This does wade a bit into hand-wavy heuristics so this behaviour should probably be behind some flag that's not active by default.
Since whoever invokes the report generator probably knows or could get to the module name, something simple like -trim-module-name="github.com.../v2"
might do in practice. It's not the most elegant of things, but it would work reliably and would work in cases people don't want the whole prefix trimmed. If we can assume the reporter is called from a directory containing the source checkout then it could infer it itself but then you'd need a boolean flag to still indicate you want it trimmed.
Personally having to explicitly pass in this data is not an issue and it avoids having to pre-process the go test
output by hand to remove the module name. That's not a terrible thing to have to do though so we might consider that the solution instead. I'd have to handle the empty string case in some shell script matching which will probably go wrong in interesting ways but not impossible. I can't quite figure out how I'd then use -p
to add the package
attribute on the testsuite
though.
from go-junit-report.
If you then end up with an empty string for
classname
, we would know we've hit main so you could substitute in the stringmain
?
Unfortunately it's not this easy. I used main
as an example, but the package name could really be anything. I guess we could fallback to for example using part of the path, but then how do we decide what to trim off and what not.
I was curious what other languages used as their classname
(if they even decided to fill in this attribute), so had a quick look around. Java+junit uses the full package name + class name and eslint appears to use the full path but omit the file extension. It seems this is more common than I thought, I'm not yet entirely convinced this should be solved within go-junit-report at the moment. It would be easy to say that this should be solved in the code that displays the results from the report, but I'm also aware that this is probably not something that's likely to be fixed anytime soon.
An alternative you could consider is to post-process the generated XML. It's not the most elegant solution, but it might be easier than attempting to pre-process the go test
output.
from go-junit-report.
Fair point about the post-processing of the report, I hadn't actually thought of that. I'll give that a go. Should be fairly easy to define some transformations to apply to it.
from go-junit-report.
Related Issues (20)
- Build failure in tests are not reported HOT 1
- TestSuite Timestamps Report All Constant HOT 6
- unable to install go-unit-report HOT 3
- after I use "go test xxx 2>&1 | go-junit-report > result.xml", then the console doesn't print any more information HOT 4
- go-junit-report is failing with command not found...
- `-version` info is "not as useful" as it may should've been HOT 1
- have an option to exclude succeeded tests
- zsh: command not found: go-junit-report HOT 4
- [no test files] Not handled well by set-exit-code HOT 1
- New release HOT 2
- False error report in case of json parsing HOT 1
- Include arm64 builds in release assets HOT 1
- gotest output from 1.20+ is not properly parsed
- `flag provided but not defined: -in` HOT 1
- go-junit-report reports success after failing to compile code HOT 1
- benchmark tests marked as error when no unit test found HOT 1
- `system-out` is never placed under the correct `testcase` HOT 2
- Consider adding an option to prevent parsing lines starting with `#` as build output
- Better support of multiple test runs (`-count`)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-junit-report.