Test list not refreshing if test project is not rebuilt
See original GitHub issueI have a use case where I get test data as names of files in the file system.
[TestCaseSource(nameof(GetAllFileNames))]
public void TestFile(string sourceFileNameWithExtension) {...}
public static List<string> GetAllFileNames() {...}
The tests are not discovered properly. The test explorer sees the list of tests from the time the project was last rebuilt, but if the file system changes and test code doesn’t the list of tests will not be refreshed. The console shows: Error] Test adapter sent back a result for an unknown test case. Ignoring result for, which I guess means that test adapter did see the change from TestCaseSource, but VS Test Explorer refused to refresh the tests list. I can get the correct behavior by manually building the project after the file system change, which is inconvenient for me.
- NUnit 3.10.1
- NUnit3TestAdapter 3.10.0
- Visual Studio Community 2017 15.5.0
- Framework: netcoreapp2.0
- Runtime: portable
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Why does my project not get rebuilt and references in ...
Currently, I am having to right-click the console app and select rebuild, then right-click the test project and select rebuild EVERY time before ......
Read more >updated tests are not compiling unless whole project is ...
Still not sure what is causing the issue - when I update the tests and rerun it, its not taking latest updates and...
Read more >Test Explorer not discoverying test methods
I created one test method in a test project in a solution, did a build, test explorer not seeing test. Close solution, open...
Read more >Intellij is not updating junit test file changes causing ...
I'm having some weird issues that started yesterday regarding unit tests. I'm not sure if they are affecting other files or not yet....
Read more >Live Unit Testing FAQ - Visual Studio (Windows)
Live Unit Testing may not work for one of the following reasons: ... by the projects in the solution haven't been restored, Live...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Discovery is being triggered by the build, and I see that when I just build (not rebuild) after adding a file, the project is being built, since msbuild detects there is a new file. However, the output is not changed, and that means that discovery doesn’t seem to be triggered, or the results not being acted upon.
So yes, I can repro the behaviour. I believe this has to do with VSTest, but I’ll check a bit more.
Steps: -I have 5 files (or whatever number you have)
The test project now looks like:
So, it seems that the VSTest discovery is somehow deciding it doesn’t need to call the adapter. I think some MSFT need to have a look at this, I’ll point them to it.
The issue has not been voted up nor commented on at the developer community site, so closing it here.