question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test list not refreshing if test project is not rebuilt

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
OsirisTerjecommented, Aug 7, 2018

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)

  • I have one trivial test, so should have 6 in total -Project is built/rebuilt and I see 6 tests
  • I add a new file
  • I just Build the solution The discovery is being started, but no new tests are discovered bilde And Test Explorer are still showing 6 bilde

The test project now looks like: bilde

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.

0reactions
OsirisTerjecommented, May 9, 2021

The issue has not been voted up nor commented on at the developer community site, so closing it here.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found