Welcome to MSDN Blogs Sign in | Join | Help

Using VSTS to do Test Driven Development

VSTS doesn't have a pure set of Test Driven Development features, but using the built-in refactoring support for C# you are able to get a good Test Driven Development experience in VSTS 2005. Test Driven Development is a methodology we greatly believe in at Microsoft, new Test Driven Development specific features might show up in future releases.

Here’s how you can use refactoring to generate shipping code from a Unit Test in VSTS. Let’s say, I need to test class A that has method “string GetData()”. I start from writing the test for it:

[TestClass]
public class ATest
{
   
[TestMethod
]
   
public void
GetDataTest()
   
{
      
A a = new A
();
      
string
s = a.GetData();
      
Assert.AreEqual("my data", s, "Wrong data returned!"
);
   }
}

I want to generate the A.GetData from this test. Well, since class A does not exist yet, I create it manually as:

public class A
{
}

All I have to do now is right-click a.GetData() in my test and select “Generate Method Stub” from context menu:

It generates the following code:

public class A
{
   internal string
GetData()
   {
      throw new Exception("The method or operation is not implemented."
);
   }
}

Now I can run the test and make sure it fails. Then I will implement GetData, run my test and fix the code, until the test passes.

Posted by mkolt | 6 Comments

Hello!

My name is Michael Koltachev, I’m a developer in Visual Studio Team System at Microsoft. Inside VSTS my team (here’s our team’s blog) works on Testing Tools and I own the internals of test execution. I could tell you a lot about VSTS and but I’d just say it’s very cool, really, we should have shipped a product with such functionality long time ago, well, it’s soon now and we have Beta 2 available. Here’s a link to blogs and forums on VSTS.

 

I am going to use this blog to post interesting information about our tools and some tips and tricks. Please share your concerns, ask questions and give feedback about our testing tools.

Posted by mkolt | 2 Comments
 
Page view tracker