lundi 23 février 2015

How to run tests from an external assembly C#

Here's what I'm trying to achieve. I'm providing some code through a nuget and want to also publish a second nuget containing tests to verify the service is working/deployed correctly. This test nuget would contain all the core tests to do so without any modification needed (except through config files).


So here's the base class from Assembly A:



[TestClass]
public abstract class BaseTestClass
{
[TestCleanup]
public void TearDown()
{
// do some cleanup...
}

[TestMethod]
public void BaseTest()
{
// base test code...
}
}


And now, I want to reference this Assembly A into another Assembly B and do something like this:



[TestClass]
public class ChildTestClass : BaseTestClass
{ }


The problem is, the test explorer doesn't see the BaseTest method. It will only see test methods that are declared in the child class itself. Any test methods from the base class are not discovered properly.


How could I do that?


FYI: it's working fine when I do the same thing but all in the same Assembly/project. I'm using both MSTest and Resharper test runner. MSTest doesn't show anything but Resharper sometimes shows the base tests but never run it, even if I'm able to select and run a specific one, it will always run only tests declared in the child class.


Aucun commentaire:

Enregistrer un commentaire