Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find unexecuted code [duplicate]

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?

like image 767
ryber Avatar asked Dec 18 '22 05:12

ryber


2 Answers

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

like image 186
eswald Avatar answered Dec 19 '22 18:12

eswald


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.

like image 40
DaveParillo Avatar answered Dec 19 '22 18:12

DaveParillo