-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trimming module name from classname #148
Comments
Thanks for the issue. I don't really know where people generally use 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 I'll have to think a bit about what the best way would be address this and how it could be configured. Any thoughts? |
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 Since whoever invokes the report generator probably knows or could get to the module name, something simple like Personally having to explicitly pass in this data is not an issue and it avoids having to pre-process the |
Unfortunately it's not this easy. I used I was curious what other languages used as their 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 |
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. |
Looking at the generated JUnit, the
classname
attribute ends up as<module>/<...>/<package name>
. So for example it'll begithub.com/jstemmer/go-junit-report/internal/junitreport
. This makes theclassname
rather long and verbose and generally has the repeatingdomain.tld/something
prefixed everywhere. In most cases this isn't very useful information and in some cases this breaks some JUnit reporting UI a bit (Gitlab renders this as a table and cells get super wide as a consequence).Having searched around a bit, it seems that in general (at least for Java), the
classname
is just that, the class, not the full import path. It's supposed to be the function under test, but we don't know that in Go so I understand why the choice was made to encode the package in the attribute instead. But I'm wondering if we can provide an option to chop the module declaration off theclassname
, so you'd end up withclassname="internal/junitreport"
instead?There doesn't appear to be an actual standard for this, but looking at the XSD for Ant a mandatory
package
key exists. JUnit 5 also has that field, but as optional instead. I'm wondering if that field could then be used to contain the module name instead?The text was updated successfully, but these errors were encountered: