Monday, September 11, 2006

Today I have tried creating unit tests using the brand new stuff from Microsoft - their unit framework that comes with the Visual Studio Team Edition. Now that was a major disappointment. I wonder how Microsoft comes out with a crappy stuff like that all the time.

The problem I have encountered is that it is not possible to use inheritance in your test classes. Take for example a base abstract class in which you define tests for your objects hierarchy. One of the method is an abstract method which returns a concrete object and the other methods are test methods as in the example below:

public abstract class BaseTest
{
[
TestMethod]
public void ConstructorParameterShouldBeSaved()
{
Guid id = Guid.NewGuid();
BaseClass obj = CreateInstance(id);
Assert.AreEqual<Guid>(id, obj.Id);
}

protected abstract BaseClass CreateInstance(Guid id);

}

Now I create another test class that inherits from the BaseTest and provides an implementation for the abstract method. Nothing an NUnit framework cannot do. But guess what? It is not supported!!! The Visual Studio complains about the TestClass attribute defined on abstract class - error UTA003.

That defeats all my desire to use MS technology so I switched to NUnit.

kick it on DotNetKicks.com