xUnit, ReSharper and Nested Classes

Hello,

Why ReSharper does not display parent classes in the "Unit Test Explorer" and "Unit Test Sessions" windows ?

Here is an example.

namespace EasyFront.Dependencies
{
     using System;

     using Xunit;

     public class DependencyRegistrarTest
     {
          private static DependencyRegistrar CreateDependencyRegistrar()
          {
               return new DependencyRegistrar();
          }

          public class IsRegistered
          {
               [Fact]
               public void Should_return_false_when_the_contract_does_not_exist()
               {
                    // Arrange
                    DependencyRegistrar registrar = CreateDependencyRegistrar();

                    Type contract = typeof(object);

                    // Act
                    bool registered = registrar.IsRegistered(contract);

                    // Assert
                    Assert.False(registered);
               }

               [Fact]
               public void Should_return_true_when_the_contract_exists()
               {
                    // Arrange
                    DependencyRegistrar registrar = CreateDependencyRegistrar();

                    Type contract = typeof(object);

                    // Act
                    bool registered = registrar.IsRegistered(contract);

                    // Assert
                    Assert.True(registered);
               }
          }
     }
}


Here is how it looks like.
unittestsessions.jpg

unittestexplorer.jpg

6 comments
Comment actions Permalink

Hello Eyal
     Have you tried playin with the grouping in the 'Group by' drop-down list in these windows? Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Yeah, I did and unfortunately it doesn't help.

0
Comment actions Permalink

Seems not to be related to xUnit nor nested classes, but rather the fact the base class does not contain any tests.
Consider NUnit structure below:

TestFixture]
    public class Foo
    {
    }
 
    [TestFixture]
    public class FooDerived1 : Foo
    {
        [Test]
        public void Derived1Test()
        {
 
        }
    }
 
    [TestFixture]
    public class FooDerived2 : Foo
    {
        [Test]
        public void Derived2Test()
        {
 
        }
    }



Reflections:
1) Foo does indeed show up in unit test explorer, however not in unit test sessions. And you can NOT select Foo in explorer to run all tests derived from it so it doesn't really help displaying it.
2) If having 1 test in Foo, it will show in both explorer and session window, but adding Foo will, as case 1, not add derived tests.
3) If having Foo abstract, it will not show up in either explorer nor unit test sessions.

I.e. in current RS behavior there is no easy way I can test all "Foo" tests, I must select 1 derived tests and e.g. select all tests in that namespace.
HTH
0
Comment actions Permalink

Yeah, I agree, it should really display the tests using the real structure of the tests although in my scenario base classes do not exist but I guess the reason that these classes aren't displayed is just like you said, no tests.

This is a major problem in my scenario because each class describe a method, I hope that JetBrains will fix it asap.

0
Comment actions Permalink

Is there anything being done ? because right now I have to see a hundreds of classes in the same namespaces ... please do something about it!

0
Comment actions Permalink

Hello Eyal
     You're welcome to vote for the following requests:

     http://youtrack.jetbrains.com/issue/RSRP-199079
     http://youtrack.jetbrains.com/issue/RSRP-266247

     Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

Please sign in to leave a comment.