Inconclusive vs. invisible unit test methods

The short story:

ReSharper’s unit test tools are there to make a developer’s life easier by decorating test cases with matching icons and providing shortcuts to commonly used functions. In some cases, however, they are just misleading…

The long story:

I’m structuring my unit tests in a nested way, as suggested by Phil Haack and several others. As I created a new ViewModel, I consequently added a new test class to my test project, started with a nested class for the first method to be tested, and instantly filled it with a first unit test method (decorated with xUnit’s [Fact] attribute).

ReSharper recognized the test method as unit test and the nested class as test collection, as it decorated the code artifacts with its unit test icons and listed the nested unit test in the test runner window:

Inconclusive unit test 1

Inconclusive unit test 2

Since this was a rather simple test case, I tried running it just to check whether I had set up the environment correctly and expected it to succeed. It did not, but most surprisingly it did not fail either – the test case was displayed as “inconclusive” in the results pane:

Inconclusive unit test 3

Inconclusive unit test 5

Now looking on Stackoverflow, Google etc., there are a lot of solutions for this problem suggested out there – reaching from changing processor architecture to repairing some misconfigured app.config files or checking for missing NuGet packages. In the end, it turned out to be a simple misconfiguration on my side – reading the detailed error message once again gave me the essential hint:

Inconclusive unit test 4

As you might already have guessed from the first screen shot in this blog post, the fault was on my side – I created the outer test class SomeViewModelTest using Visual Studio’s Add new item wizard, as this creates a new file containing the namespace and class identifiers, but does not mark the newly created class as public! I did not realize that in the first run, and started typing the nested class and test method, but as long as the outer class is not marked public, it seems to not be visible to the ReSharper test runner!

By the way, after the first unsuccessful test run, ReSharper seemed to realize its mistake, and changed the icons displayed next to the nested class and test method in the code editor to the more verbose Invisble icon:

Inconclusive unit test 6

The only remaining question is: Why not using the correct icon right from the start? Would have saved me a lot of time and headache…