-
Notifications
You must be signed in to change notification settings - Fork 106
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 Adapter runs explicit tests when TFS TestCaseFilter is used #47
Comments
The 2.0 issue, nunit/nunit-vs-adapter#71, suggests two ways to deal with this problem:
Upon further review, (2) is not a solution. Tests need to be removed only if the filter does not explicitly select them. So, we have to parse the filter expression in either case... for (1) so we can generate the nunit filter and for (2) so we can retroactively correct the selection made by the filter in the first place. If we have to do so much work for (2) then I would lean toward (1) as the best approach. That decided, however, another big choice looms! In the V2 adapter, we implemented the use of MsTest-style filtering because it was the easiest approach. NUnit V2 didn't have it's own filtering language. But in NUnit 3.0, we already have a filtering DSL, which is used by the console runner and is implemented as a service of the TestEngine. In fact, we could trivially transform an expression like "cat==Data || Priority == High" into a set of NUnit test filters. We could also, with a bit more work, make a copy of our existing code to parse our DSL and change it to parse MsTest-style filters. As with our existing code, we would emit an nunit filter that honored the Explicit attribute. Of course, this would give us two DSLs to support and for users to remember. Options:
@OsirisTerje @rprouse What do you think? |
I can't get TestCategoryFilter to function at all in TFS 2015.1 build vNext with NUnit adapter 3.0.9.0. Is this related? |
@jnm2 No, this issue is a pretty well-known problem. I haven't tried vNext at all. If the problem persists, you may want to file another issue, showing details of what you are doing and what is happening (or not). |
Any rational way forward on this issue involves parsing the filter expression. Parsing the filter expression requires deciding on the filtering DSL we want to support. The leading choices are our own existing DSL and the MsTest one. Nobody is giving any feedback on the choice here, so I'm pulling the issue out of the milestone. Perhaps we can refer it to the general community for a future release. |
@OsirisTerje Nobody has ever responded to my request for comment on this, so I think it's up to us to decide what to do. Do you think we should continue to support the MsTest-style filter expressions here, require use of our own expressions as used in NUnit3-Console's --where option or support both? Any option that supports MsTest-style filters requires us to parse them, of course. I'd like to either decide to move ahead with this in a certain direction or simply to say we are not planning to fix it. |
I raised nunit/nunit#1664 and was directed here. Can some please confirm whether this issue also represents the problem purely in the VS Test Explorer, regardless of TFS? I'm not using TFS, but when I run "all tests" in the VS Test Explorer, tests marked |
@adamralph yes this is an issue with just VS Test Explorer also. |
Thanks @rprouse. That's not at all obvious from the title and description. Would it be worth refining, to make it easier to find for anyone else having the same problem? This is the reason I couldn't find it when I searched, and why I raised nunit/nunit#1664 instead. |
@CharliePoole shouldn't MsTest-style filters be supported in the vs-adapter anyways, so that it correctly works from within Visual Studio and TFS-Build? |
@rprouse Are you sure @adamralph 's problem is the same? In nunit/nunit#1664 he talks about using Run All from the IDE and doesn't mention any use of filters. Obviously it is an adapter issue, but I'm not so sure it's the same as this one. @adamralph Can you comment on this? If we can't draw a connection with this one - i.e. if no filters are involved - then we will need to confirm it separately. It's not a problem I have ever seen. Specifically, the NUnit 3 Test Demo project contains tests marked explicit and they are handled as expected. |
I believe @adamralph's problem may also be with the v2 adapter rather than this one, I had a quick dig earlier. @adamralph - is that correct, the issue was with the NServiceBus tests, running NUnit v2.6.4? |
@dnfperfors There's no requirement of supporting MsTest style filters in order to run under TFS and the IDE. The user supplies the filter as an expression and it's up to the adapter to interpret it. The solution to this problem requires a significant amount of work - but rather interesting work if you like parsing. It can go in two completely different ways, so I asked for feedback three months ago. Yours is the first reply. Our options are:
Permit me to briefly rant... I've been working on NUnit for about 14 years now. When asking for feedback, I have often been told "Just do what you think best - you're the one working on it." In many cases, I have taken this to heart because at least it gives a decision and we can move forward. That approach doesn't work for everything, however. Sometimes I absolutely need user input, so I ask for it. This is such a case. Because we are talking about a feature that I personally never use, I can't have an intelligent opinion about it. All I can do is outline the options and the pros and cons that I see. Others have to respond to that if they want the thing to move ahead. If not enough people care strongly enough to give some feedback, then it doesn't move. There are other things in NUnit that I feel strongly about myself, so I focus on them. End of rant... Currently this issue is in the 3.5 milestone but with nobody assigned. That''s a bit of an anomaly. I put it there in the hopes of drawing attention to the fact that it is blocked. I should have marked it blocked, which I just did, for the reasons explained above. |
@ChrisMaddock Good on you for noticing that. We only have a one line problem description from @adamralph so let's wait for more information before replicating this anywhere else. |
I'll try and push a repro solution to GitHub some time tomorrow. |
@CharliePoole I had assumed that Run All was passing an MSTest style filter with the list of all tests to run and that is why the explicit tests are being run, but I haven't debugged it, so I might be mistaken. I am seeing the same behaviour in the .NET Core adapter. |
@rprouse If it's doing that, it's new behavior on VS's part and violates their documentation, which explicitly states that the kind of filter we use is up to us. I'll check in the debugger with VS 2015. |
@CharliePoole, thanks for the explanation. I don't think we use the MsTest-style filters and even if we do, it would be no problem to change them to the NUnit-style filters. So I would opt for the quicker solution of at least start supporting the NUnit filters in 3.5 and, if necessary, include support for MsTest-style filters later. |
If you decide to unify it, and have explicit tests skipped in both scenarios, how would you like the user to opt in and run explicit tests? When we get to the implementation phase, integration tests would be nice. |
Options: Note that the only thing we don't do then is to allow an explicit test to be run because it is part of a test fixture marked with another selected category. I don't understand the logic of this though (my understanding of this might even be wrong).
|
Looking back before moving ahead (in the next comment)... @OsirisTerje You summarized my options as follows:
That's not quite it. In my comment back in April, 2016 🙄 I suggested four things...
By "support" I had no intention to suggest that vstest-console would accept our own syntax. I assumed we would have to provide it through the My own preference these days is 1 + 2. Command-line filters would have to use the VS format. Adding our own syntax as a runsetting would be an extra. |
@OsirisTerje Why do we need a command-line switch to run explicit tests? We don't have a way to do this in the console runner and the framework has no way to overrule explicit except by specifically selecting the test. Selection can be by name, by category, etc. In any case, if you feel we need this new feature, it's orthogonal to the purpose of this issue, which is to stop running explicit tests when they are not selected. |
@OsirisTerje I'm not understanding the "extra" bug in the V2 adapter. You state that explicit tests are skipped when no filter is used. That's correct behavior. Is there some other bug? |
@OsirisTerje You wrote
I think you mean something like [Category("X")]
public class Fixture()
{
[Explicit, Test]
public void TheTest() { }
} When running category "X", |
I wish category selection was in the same genre as parent selection so that it would never explicitly select a test case. I can't imagine thinking of a category as a way to single out an explicit test. But that's determined by the framework. |
I think that one thing being missed in the discussion is the purpose of Explicit. It was designed for use on tests that one does not normally want to run as part of the CI build. In rare cases, one may want to override this behavior, which is possible through explicitly calling out the test to be run. A situation where you want to run all your non-CI tests in the CI build seems pretty far-fetched. For example, I use
I would never want such tests to run in CI. |
@CharliePoole Thanks, the comments above really cleared it out for me. :-) Then we have the default behavior cleared out, (stop running explicit tests) and we should get that fixed. (My pt.1. above). We should have this in with 3.10. To allow people to run explicit tests, I think the parsing to NUnit filter and letting the engine do the rest, is the best way to go, since, if I understand the engine correctly, it already has that functionality. But, it takes some more time to implement that. I'll add a separate issue for implementing that post 3.10, for 3.11. We can then just auto-add Explicit as a category, as was suggested above, which would also provide grouping in the UI as @rprouse points out, and it "unblocks us from blocking" when we implement the default behavior. And if someone really wants to run them in CI, they can. Even if I agree with @CharliePoole , can't really see why. But at least we don't block anyone. We do this in 3.10. @CharliePoole The bug in NUnit2 adapter is that it runs explicit tests when any kind of test filter is added, even if it doesn't points to the explicit test. So based on our earlier chat about that, we should fix it there too. |
@OsirisTerje That clears things up for me. We should continue the chat we started offline as well. That will help me figure out where or if I can help you. |
@OsirisTerje Is there a schedule for 3.10? |
It's not impossible that people might use |
@CharliePoole Yes, it is scheduled for release by the end of the month, that means, I hope to have it out by the end of next week. |
If I understood right, @OsirisTerje slated this for 3.10:
And this for 3.next:
@OsirisTerje Any details missing for the 3.10 work? |
Seems correct , thanks! |
Should we start a new issue for 3.11 to discuss ways to run explicit tests from the command line? |
@jnm2 Please do |
Done! #473 |
See the original issue filed against the 2.0 adapter: nunit/nunit-vs-adapter#71
The text was updated successfully, but these errors were encountered: