4

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?

ChrisF
  • 134,786
  • 31
  • 255
  • 325
ryber
  • 4,537
  • 2
  • 26
  • 50

3 Answers3

11

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

Community
  • 1
  • 1
eswald
  • 8,368
  • 4
  • 28
  • 28
  • +1 short & sweet. Not enough people refer to existing good answers that are out there. – DaveParillo Oct 19 '09 at 22:49
  • 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 Oct 19 '09 at 22:49
  • 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 Oct 19 '09 at 22:50
  • 1
    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 Oct 19 '09 at 22:58
1

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.

Community
  • 1
  • 1
DaveParillo
  • 2,233
  • 22
  • 20
0

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
  • 442
  • 1
  • 11
  • 22