Test As You Type With NCrunch for Visual Studio
Using NCrunch to analyse the state of a projects testing after some significant changes.
It’s easy to fall into a trap of seeing high % code coverage numbers and lots of green checkboxes on your tests and feeling like your testing is in a great place.
While high % code coverage on your tests is obviously good it’s important to have a way to easily see these numbers at a glance and see your coverage gaps.
Install the NCrunch extension for visual studio.
Once installed see the NCrunch icon at the bottom right of visual studio.
Checking coverage gaps
After running all your tests check the Ncrunch metrics to see your coverage.
In this example the services hold most of our business logic so I want to have a look now at each service to spot gaps that should be covered by testing.
Easily spot code not covered by any test with the white markers. In this example we are simply throwing an exception to display an error message to the user. At a glance I can see that this is a low priority gap.
Finding high priority code that isn’t covered in the same service. Can see at a glance that although the function is tested our model now has a new list that needs to be managed “JobRoleLinks” and we will need to write tests to cover this new functionality.
Even with high test coverage % and making sure each function was tested it would have been very easy to not test how the new list of objects on our model is being handled.
Checking for performance issues
After test execution check hotspots section to find potential performance issues in the code.
These sections of code may take a few milliseconds during testing but how will they function with much larger data sets in a live environment?
As with a lot of these tools they require a lot of overhead and can slow down your IDE.
If the IDE is suffering simply disable the extension until test/performance analysis is needed.
If you would like to learn more about how we are helping our clients address their critical objectives, while also building their internal capabilities and tapping into the true potential that their own resources have to offer, contact us or call us today on 051 878555.
To stay up to date with Dataworks Limited news and events, connect with us via the links below:
DATAWORKS – Driving Digital Transformation in the worlds’ Leading Life Science Companies
for over 25 Years