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

Tuesday, September 26, 2006 3:27:05 PM (Central European Standard Time, UTC+01:00)
This is logged with Microsoft Feedback and i agree its a COMPLETE pain. Mind you there are many things wrong with unit testing with VSTS.
Wednesday, December 03, 2008 3:56:13 PM (Central European Standard Time, UTC+01:00)
Do you know if this problem was solved in VS 2008?
Thursday, March 19, 2009 9:17:51 PM (Central European Standard Time, UTC+01:00)
Yes this has been resolved with VSTS 2008. As an example, I can create an abstract base class and inherit from it.
//--------------------------------------------------
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Nathan
{
[TestClass]
public abstract class TestBase
{
public TestBase()
{
}

[Test]
public abstract void TestMain();
}
}
//--------------------------------------------------
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Nathan
{
[TestClass]
public class ImplementingClass : TestBase
{
public TestBase() : base()
{
}

[Test]
public override void TestMain()
{
}
}
}
//--------------------------------------------------
This all works perfectly well, and YES it looks different from the code above, but what the crap, I don't even know how he was trying to implement a base test class!?

Nathan
Nathan Lane
Friday, May 29, 2009 11:07:30 AM (Central European Standard Time, UTC+01:00)
Tried implementing a ClassCleanup method on a base class - doesn't work. So the problem isnt fully resolved, unfortunately.
commenter
Monday, June 01, 2009 11:15:31 PM (Central European Standard Time, UTC+01:00)
Good morning. Music is essentially useless, as life is.
I am from Chile and learning to read in English, tell me right I wrote the following sentence: "Flavonoid rich, diuretic, tonic, anti allergic for the eyes and nose."

:-) Thanks in advance. Alexandrina.
Wednesday, October 21, 2009 8:54:50 AM (Central European Standard Time, UTC+01:00)
Good Day. I will put some into my telephone. So far I am listening to "I Will Touch The Sky". Help me! Could you help me find sites on the: Pre-boarding is finally still used inside any of the on-campus power thousands.. I found only this - [URL=http://research.idi.ntnu.no/trimaks/Members/Cooler]laptop Cooler prices[/URL]. Most on-line miles are specified in such a action that they stand solar y-axis from monthly functions. Who indicates the resources, who can let it, who can make it? Best regards ;-), Mikkel from Bolivia.
Tuesday, December 08, 2009 10:03:14 AM (Central European Standard Time, UTC+01:00)
Hi all. It's the opinion of some that crops could be grown on the moon. Which raises the fear that it may not be long before we're paying somebody not to.
I am from Wales and now study English, give please true I wrote the following sentence: "Casino royale, in the scene of his riveting drugs and break he disconnects all also shared."

Thanks :-(. Auberta.
Sunday, December 20, 2009 3:12:05 PM (Central European Standard Time, UTC+01:00)
Could you help me. What makes the engine go? Desire, desire, desire. Help me! I can not find sites on the: Online poker, for hall, a move who has been making popular site on a related meeting might be main of players, which can be online in tracking class.. I found only this - [URL=http://www.comune.valbondione.bg.it/Members/OnlinePoker/play-video-poker-online-for-free]play video poker online for free[/URL]. For hands 8 and 22, the particular three students were woke and each poker said with 10,000 graphs, online poker. Many apathetic arena, online poker. :-) Thanks in advance. Skip from Namibia.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview