CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeffrey Palermo (.com)

Blog moved to www.jeffreypalermo.com

Visual Studio Team System "unit?" testing, integration testing and DDT - Development-Driven Testing - level 200

Dr. Neil calls Microsoft out for their attempt to redefine Test-Driven Development to suite the product they have developed (Team System).  I personally thing VSTS will help a great number of teams define a process for their group.  Many development team I talk to don't have an actual process.  It's more of the wild west.  I use a mixture of XP an Scrum, and our Agile practices are very structured and disciplined.  Waterfall falls somewhere in the middle on a discipline scale (and far out there on a reality scale).  For cowboy teams or teams whose process isn't reliably producing working software, I think VSTS will help to inforce a more disciplined and accountable software shop.  Along with any product, it will be both abused and used for good.  Kudos to Microsoft for putting this product together.

With all the good that it will bring with it's increased focus on automated builds, static code analysis and automated testing, it has missed the boat on a few items regarding it's automated testing support or what it claims to be.  VSTS does come with testing support, and it can generate test stubs from production code, but it does not inherently support test-drivent development.  TDD is simple:

  • RED (make a test, and make it fail)
  • GREEN (write production code to make the test pass)
  • REFACTOR (eliminate duplication)

It's a cycle of 1 test to 1 production scenario, and TDD is test-first unit testing that helps shape the design of the production code as it emerges.  Development is "test-driven".  That means that if you are developing and then generating tests, you are doing testing, but your development wasn't "test-driven", it was "test-trailored", or whatever term you want to use.

VSTS testing tools will generate test stubs from production code, but they won't generate a production method stub from a test (which is a well-used feature of Resharper).  If you look at the process guidence on TDD from Microsoft, you'll notice the attempt to redefine the process to fit the tool.  They should modify to the tool to fit the already-proven process.

Another falacy exists in the guidance on creating "ASP.NET unit tests".  Microsoft seems to only focus on unit testing as a term, but they describe integration tests.  Refer to Jeremy Miller's post about the different types of tests.  Unit tests test code in isolation.  In other words, they test code while isolating dependencies from the code.  Unit tests should always pass.  Unit test only run custom code.  If 3rd-party libaries or frameworks are required for a test to pass, then it is, by definition, not a unit test.  It then becomes an integration test.  The term "ASP.NET unit test" is a falacy.  These tests, as Microsoft describes them, include the development webserver in the testing stack.  This is a pretty significant dependency, and these are integration tests.  Integration tests are important too, but they should be defined correctly.



Comments

Jeffrey Palermo said:

Obie Fernandez has some interesting comments about TDD on his blog here: http://jroller.com/page/obie?entry=design_trumps_tdd
# October 17, 2005 2:41 PM

Dennis van der Stelt said:

Unfortunately Visual Studio 2005 RTM isn't online, as Jeffrey Palermo 'promised'. Strange enough his...
# October 18, 2005 5:34 AM

Dennis van der Stelt said:

Unfortunately Visual Studio 2005 RTM isn't online, as Jeffrey Palermo 'promised'. Strange enough his...
# October 18, 2005 5:35 AM

Brian R said:

I understand what you are trying to spell out to your readers, but test driven development can still be performed with VSTS. The truth is, MS built in the functionality to stub out unit tests, which is a nice feature if you have something that doesn't already have unit tests against it. Nothing says this is how you should develop though. You can write a unit test first, and then write the production code to make the unit test pass. Sure, Resharper has a feature that Team System does not, but that doesn't make TS un-usable, or even hard to use, with test driven development.
# October 18, 2005 11:21 AM

Jeffrey Palermo said:

Brian,
You are absolutely right, and I will surely be using it to do TDD. You don't need a specific IDE to do TDD. Specifically, their process guidence recommends creating production code and then generate tests for that, and that's backwards. TDD recommends creating a test and then production code that satisfies the test.

# October 18, 2005 11:49 AM

Mike Gale said:

I think flexibility of thought is very important here.

People are going to have different approaches at different times.

I regularly need to catch myself to drop the "unit test" phrase and replace it with "test". Reason: I don't limit myself to pure unit testing, I do what is needed for the task at hand. That's often "integration testing", invariably mixed with "unit testing". For me it's just testing, the right testing.

Aspx testing is very important. Those who have tried to do it in the past know how much of a barrier that "web/app server" layer addds. (Sometimes make you wonder whether the who code drive web site idea has gone horribly wrong!) A lot will rejoice at this capability.
# October 18, 2005 2:57 PM

Dennis van der Stelt said:

I think VS2005 works great for TDD.

You can use the Class Designer for UML as Sketch (Fowler), where you draw UML in VS2005 and the raw classes are just transformed into clean classes. Create a test project, a reference to the implementation, create a test, and create a implementation stub. It _IS_ possible to create an empty method from a test.

More can be found on my blog, where I specify what I've done myself to come to the conclusion.
# October 19, 2005 2:06 AM

Dennis van der Stelt said:

Whoops, moderating comments without getting noticed by Community Server isn't the most pleasant way to work.

I've noticed now Jeffrey replied.

I think we're both on the same track. Jeffrey was especially commeting about generating your tests from (empty?) classes. What I did was create empty classes, a test project and a test. Then created an implementation method from my test-method. This implementation method was the first method in my class, so it'd be impossible to generate ANY test any sooner.

I like the way it works, hope they fix the bug that VS2005 doesn't notice all called methods don't exist.
# October 19, 2005 4:09 AM

DawlinLi said:

Hi,

How do I unit test for event triggering? How can I check whether an event has been fired?
# October 27, 2005 9:54 PM

Dennis van der Stelt said:

Unfortunately Visual Studio 2005 RTM isn't online, as Jeffrey Palermo 'promised'. Strange enough his...
# November 22, 2005 2:12 AM

EZWeb guy: Jeffrey Palermo [C# MVP] said:

If you remember the article in October that was on MSDN on Test-Driven Development, you remember the...
# May 18, 2006 7:55 PM

About Jeffrey Palermo

Jeffrey Palermo is a software management consultant and the CTO of Headspring Systems in Austin, TX. Jeffrey specializes in Agile coaching and helps companies double the productivity of software teams. Jeffrey is an MCSD.Net , Microsoft MVP, Certified Scrummaster, Austin .Net User Group leader, AgileAustin board member, INETA speaker, INETA Membership Mentor, Christian, husband, father, motorcyclist, Eagle Scout, U.S. Army Veteran, and Texas A&M University graduate. Check out Devlicio.us!

This Blog

Syndication

News

Headspring Systems

View Jeffrey Palermo's profile on LinkedIn

See my new blog at .jeffreypalermo.com