-
Notifications
You must be signed in to change notification settings - Fork 153
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
Explore command (--explore) does not report issues while generating Test Cases #658
Comments
IIRC we once had a specific error for this situation (filter specified with no matches found) in NUnit V2. I suspect it got lost because it was unclear where the responsibility for an error should lie. I think the runner is the right place. If the framework is called with a filter that gives no matches, it should simply return no matches. The framework doesn't know why it was called. Maybe it's being called on multiple test assemblies, for example, where only one of them will have the match. Similarly, I don't think the engine should give an error for exactly the same reason. That leaves the console runner itself. It knows that the user expected to find some specific tests with one or more assemblies or projects. If none are found, it can point that out. However, in the case of explore or run, it can only do that if no tests are found. If some are found, but not all those you hoped for, it doesn't seem as if we can do anything more. The invalid suite is displayed on a run or in the XML output of explore. The default explore lists only test cases, so of course it won't show test cases that were never created. In retrospect, --explore's default output may not have been the best choice. 😞 |
I believe issue 1 is a duplicate of nunit/nunit#1381 (Although an excellent bug report for it - much appreciated!) This one, I agree is a clear cut bug which should be fixed. I'm not totally sure off the top of my head if the code to do this lies in the framework or engine. (I think perhaps framework?) Issue 2: my expectation is that this console method would still load the entire assembly first, and I would expect this to fail at that point. (At least up until we implement #384!) The exception must be being swallowed somewhere, and I would argue that if you fail to build all test cases, the only 'known' you have is that you can't return a full response to the test filter, so the test run should fail. @DominikJaniec - We'd appreciate pull requests for these issues, if you'd be interested? (But I would wait for some more members of @nunit/engine-team to comment first - as Charlie and I perhaps disagree on the desired behaviour!) |
Just to be completely clear, I would propose the following:
Charlie - what do you think? 🙂 |
@ChrisMaddock thank you and yes, my main issue is sort of duplicate of #1381, however both
I fully agree with your first bullet. However, I think I like idea of selective loading of tests and also current behaviour: execution of all requested tests, even thou generation of cases failed for some but other (not requested) tests. And about my possible contribution, I'm not sure if I'll manage, but I may take a look, when everything will be settled and it won't require to turn everything out. |
I found strange inconsistency in behaviour of
NUnit.ConsoleRunner
between explore and execute when there are "problematic" test cases - i.e. an exception thrown when resolvingTestCaseSource
values. Generally speaking, I would like to:--explore
) didn't went quite well, as there were issues with generating cases.If current behaviour is "by design", I would be very glad to get an explanation why there is such difference. Also, I would like to find such information in documentation, but I was unable to.
I'm also very surprised that NUnit will not complain much, when it was instructed to execute test (by "exact name"), but such test could not be found (e.g. nobody yet created one). It looks risky (at least for me), to return
0
when no test (especially requested) was executed, as it will hide issues with infrastructure which uses NUnit (e.g. incorrectly provided tests names). On the other hand, it is not my main concern here.Nonetheless, I've prepared demo (NUnitInconsistency.zip, sources), and I believe that my explanation isn't convoluted much. All outputs are trimmed to significant ends.
It is a simple .NET (4.7.1, class-lib) project with NuGet dependencies to
NUnit
(3.12.0) andNUnit.ConsoleRunner
(3.10.0). It is basically single C# file, which is relevant for this issue:(I) When it's compiled (after NuGet restore, then
Debug
build), tests could be executed and given assembly can be "tested" via console (cmd.exe
):(II) Also tests could be "explored" to find their "exact names" in given compiled assembly:
(III) Everything works fine and as expected. However, let's assume that we encounter some problems while generating cases (just change
ShouldCauseProblems
totrue
and rebuild). So as a result, when executing tests, we will get appropriateExitCode
, and expected Overall result: Failed with detailedexception & stack-trace
(omitted here):(IV) Nonetheless, under those circumstance (problem with generating test cases), when someone would like to find what tests are available in given assembly, they will get "everything" without problems, but at the same time, tests will be generated without arguments in names (i.e. just name of test), and nobody know that there is an issue:
(V) I guess, it is not a big deal, as one can always execute all test under its common name (i.e. without any arguments), and when there is a problem with generating cases, you will find expected behaviour - very similar to (III):
(VI) In like manner, let's assume that one has got full names of tests with arguments, and only later, the issue with generating test cases come up, but nobody knows that yet. Then, one tries to execute single test by its "exact name":
Clearly "no tests executed", but also no errors printed - with information that such test case could not be found, as no cases could be generated. Moreover, let's assume that the one is a script (CI/CD agent) and doesn't care about output, it only care about exit code, but in such case, everything went OK, as
%errorleverl% is 0
.The text was updated successfully, but these errors were encountered: