-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Test that runs really fast is indistinguishable from a filtered test in the test.xml. #3201
Comments
@damienmg Is there a way to distinguish these two situations? |
I don't think so. /cc @iirina because that's from the Java Test Runner |
Blaze sets an extra |
Right now the ant xml writer doesn't display if the test was run or not, but it can be change to do so. |
The XML schema used by surefire is here: http://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd Possibly the |
I want to implement this using @kcooney's suggestion, supplying the Do you think this is an acceptable solution? |
Ok, after further analyzing the situation, I think I misunderstood the initial intent. It seems, as @chaoren reported, that test.xml will contain all test cases, even those filtered out by I think a much better solution would be to use check whether or not a test case is filtered, before adding it to the model. Test cases that were filtered out should not be added to the test model at all. WFYT? |
Ok, even further digging. The issue, seems to me, is with the Maybe there's a way to only memoize the |
(last update, promise :))
The question is, how expensive is the test model creation, and can it be memoized only after applying the filters? |
@hmemcpy Having details about all of the tests can be very useful. For example, for a sharded test run you can combine the results from all shards to give a consolidated view of the test results from all shards, even though each shard has the result for some of the tests. As for what to do with You can determine which tests are filtered by looking at the TestResult and calling My guess is the fix will be around here. The challenge with this bug is that the Ant/Maven XML test format isn't very flexible, so can't represent all of the possible states that the Bazel JUnit runner supports. I don't know enough about the open source tools that process the XML to know what changes Bazel would need to make to the generated XML so that those tools can identify filtered tests. Maybe we just don't include them in the XML. Maybe we include them, but specify an attribute that indicates that the test was not run. It's hard to know which to do without understanding the tools that process the XML. This is why I suggested looking at what XML Maven Surefire would produce for these kinds of use cases. If we could match what Surefire does we are more likely to work with tools that process the XML. |
Kevin, thanks for the detailed answer! To be sure, I ran the FooBarTest example with Maven Surefire, using Your suggestions about the possible fix sound reasonable - to actually fix this in the I was toying with the idea to allow providing an external xml producer (#4507) instead of the AntXml one, so that different runners could provide their own format, but as you mentioned - we don't know what other tools rely on the Bazel-flavored xml report... |
@hmemcpy sounds like you can update |
@kcooney in that case, the fix seems trivial: add a check in |
@hmemcpy if all test cases in a test class are filtered out should we emit a |
Good question... I think so, since we still would like to show it as an element in the UI (intellij), I think, it just won't have any test cases... |
We found a problem with this patch... seems that tests that are added dynamically by the test runner (in our case, specs2 'examples' that are generated with In the meantime, and after a discussion with @ittaiz, I'd like to ask to revert this PR to prevent broken reports. |
As a maintainer of JUnit I'd like to point out that i am not sure if dynamically-created tests are officially supposed for JUnit4-style tests (by "dynamically-created" I mean tests that don't exist until the test starts running). It may happen to work, but there is no framework support for it, and any extensions using test listeners (including some built-in rules) may behave in odd ways. JUnit5 does support it for Jupiter-style tests. @hmemcpy did you verify that dynamically-generated tests were included in the XML before Bazel had this change (and had the correct status on pass/fail)? Could you perhaps write a test in the test suite for XML writing that verifies the regression so Bazel doesn't break this in the future? Can we fix forward instead of roll back? |
@kcooney hey, I may have described it wrong by calling them "dynamically-created", but yeah, before the check for |
FYI I am not on the Bazel team (I just worked on parts of the JUnit integration). Hopefully someone on the team will so a roll back. |
… On Thu, 8 Mar 2018 at 18:57 Philipp Wollermann ***@***.***> wrote:
@hmemcpy <https://github.com/hmemcpy> @ittaiz <https://github.com/ittaiz>
I'll send a rollback for this and make sure that it will be part of the
next release.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3201 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF1IbDJTn6w2nMRLWcsr4cFFHNYu-ks5tcWLjgaJpZM4N7wCR>
.
|
*** Reason for rollback *** Rollback was requested by original authors @hmemcpy and @ittaiz in #3201: "We found a problem with this patch... seems that tests that are added dynamically by the test runner (in our case, specs2 'examples' that are generated with Fragments.foreach) do not appear in the xml!" This should be part of 0.12.0-rc1, otherwise that release will have the above mentioned regression. *** Original change description *** Skipping writing FILTERED tests to test.xml This fixes #3201 by preventing tests that haven't actually run to be written to the test.xml. This is consistent with how e.g. surefire reports work, tests that were filtered out do not appear in the xml. This allows changing the Bazel plugin in such a way that does not depend on `time` being 0.0. Closes #4596. PiperOrigin-RevId: 188455315
After further analysis, I pinpointed the source of the problem -- it has to do with the value used for I've sent a PR to the author of specs2, so it should be fixed in future versions. This PR is good to go as-is. Can you please reapply the commit, or should I send a new one? @philwo |
@hmemcpy No problem, I can just revert the revert automatically. Just to make sure: In your research you found out that the original code in this PR was fine (the bug was in a third-party library) and thus we don't have to cherrypick the revert into the 0.12.0 releaes anymore, right? |
*** Reason for rollback *** Rollforward as requested by the original author @hmemcpy. *** Original change description *** Skipping writing FILTERED tests to test.xml This fixes #3201 by preventing tests that haven't actually run to be written to the test.xml. This is consistent with how e.g. surefire reports work, tests that were filtered out do not appear in the xml. This allows changing the Bazel plugin in such a way that does not depend on `time` being 0.0. Closes #4596. PiperOrigin-RevId: 189610180
@philwo yeah, the original PR was fine, we're good in having it in 0.12.0. Thanks again! |
I believe Jukito can also create multiple identical Description values for parameterized methods, so some users will see issues there. I wonder how other build tools handle it; from JUnit's perspective it can't tell which result comes from which test. |
Please provide the following information. The more we know about your system and use case, the more easily and likely we can help.
Description of the problem / feature request / question:
If asking a question or requesting a feature, also tell us about the underlying problem you're trying to solve.
Test that runs really fast is indistinguishable from a filtered test in the test.xml.
If possible, provide a minimal example to reproduce the problem:
In both cases the result of
testFoo
is justit makes it hard for us to display this in an IDE.
Environment info
Operating System: GNU/Linux
Bazel version (output of
bazel info release
): release 0.5.1If
bazel info release
returns "development version" or "(@Non-Git)", please tell us what source tree you compiled Bazel from; git commit hash is appreciated (git rev-parse HEAD
):Have you found anything relevant by searching the web?
(e.g. StackOverflow answers,
GitHub issues,
email threads on the
bazel-discuss
Google group)Anything else, information or logs or outputs that would be helpful?
(If they are large, please upload as attachment or provide link).
The text was updated successfully, but these errors were encountered: