views:

149

answers:

3

Greetings,

I have a large number of fitnesse tests for a project (1000+). Over time as features change, and shared fixtures come and go we have been left with unused orphaned code. But how to find it?

For those who don't know how fit works, you have a wiki page with a like like this:

| When a User Adds | 1 | and | 2 | He is returned | 3 |

Which is mapped at run time to a method like:

public bool WhenAUserAddsAndHeIsReturned(int first, int second, int expectedResult){

    return ((first + second) == expectedResult)
}

finding all of these mappings by hand would be drudgery, writing a script to do it would be a long and difficult task. Im sure there must be a better solution.

Is there a utility out there that could monitor the fixture dll while the tests are running and then return a list of all classes and methods that were NOT run?

+10  A: 

The key word you're looking for is coverage. Question #276829 covers some of the options for your C#/.NET platform.

eswald
DaveParillo
That would do it if he was looking for 100% method coverage during his unit testing, but does that tell you whether the methods [would] actually get executed during normal program operation?
Robert Harvey
I was aware that nCover and the like will give you data like this while running unit tests...in fact nCover has its own nUnit runner as part of it's process. But I was not aware it can be used to analyze a dll under other situations. Ill have to look into that.
ryber
Robert: He asked for something that points out code that doesn't get run while his tests are running. That's what a code coverage tool does. The fact that he intends to use it to trim out dead code doesn't make it the wrong tool for the job.You're right, though, that it's worth checking each piece of untouched code to see whether it's truly dead or simply untested.
eswald
OK. Got it.......
Robert Harvey
+1  A: 

Related to coverage are profiling tools. See this post for .Net recommendations. These tools tell you where your time is spent during execution, not necessarily when your code didn't go, but you can use them to find the dead code.

DaveParillo
A: 

eswald is right, Coverage tool is exactly what you need. Our ccNet build server runs our Fitnesse tests (and unit tests) with NCover to check how well we are doing with automated testing of the application code. This question a nice reminder to check the coverage reports for dead fixtures.

Lee