Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run all the unit-tests of the TestClass together with its inner TestClass tests?

I have inner classes to unit-test instance methods like below.

My problem is when I go to FooClassTests and use VS to run all tests in context, it skips the inner class tests.

If you are using this structure, do you know how can I run all tests together with the ones in the inner classes?

[TestClass]
public class FooClassTests
{

    [TestMethod]
    public void CanGuardConstructorParameters()
    {
        // Asserts here
    }

    [TestClass]
    public class DoWorkTests //Tests method DoWork
    {
        [TestMethod]
        public void CanDoTheWork()
        {
            // Asserts here
        }
    }
}
like image 298
pencilCake Avatar asked Sep 17 '25 18:09

pencilCake


1 Answers

Via Visual Studio Runner I don't know but this is supported in NCrunch. This is how I structure all my tests.

See http://www.ncrunch.net/

This guy seems to be using it fine in MS Test too:

http://zendeveloper.blogspot.ie/2012/01/structuring-unit-tests.html

And I am almost certain that these type of tests work in resharper's test runner.

like image 142
deanvmc Avatar answered Sep 20 '25 08:09

deanvmc