I am in the process of writing unit tests for someone else's code. Right now, I am just sort of looking through all the classes of the main code branch to see if I have written tests to cover all cases. What sort of tools exist that could aid me in this to see how many more tests I still have to write?
-
This question is really about code coverage. Unit tests are just a way to exercise the code, for which one might want code coverage. There are many other ways to exercise code, for which one might also want code coverage. – Ira Baxter Jun 6 '15 at 9:32
StackOverflow has a rather extensive post which details many of the available code-coverage solutions for C#/.Net. Content reproduced below, and all credit should go to the users of SO:
- NCover
- Seems to be very popular and looks quite good
- Supports statement coverage and branch coverage
- $658 for a Desktop License
- Older Beta-Versions available for free
- Visual Studio (2008 Pro) | (2005 Team System (Development, Test or Team Suite Editions))
- Well, it's Microsoft so I'd expect it to work properly
- Fully Integrated into Visual Studio
- At least $5,469
- PartCover
- Open Source
- Supports statement coverage
- OpenCover - successor to PartCover
- OpenSource
- Supports branch and statement coverage
- 32 and 64 bit support
- Silverlight support
- Background
- SD Test Coverage
- Works with 32 and 64 bits
- Works well in embedded systems (e.g, phones) and with Mono
- C# versions 1.2 thru 7.2
- Handles both small and very large code bases
- $250 for single user license
- JetBrains dotCover
- $100 for Personal License
- Supports statement coverage
- Silverlight support
-
- $159 for personal license
- $289 for commercial seat license
* Free during beta, to become commercial, pricing unknown future unknown. - Code coverage indicators in Visual Studio
- Continuous (near real time) testing
- Visual per-test code coverage
- Performance metrics, parallell multi-core test execution
-
- $410 for developer license
- NDepend can import coverage data from NCover, DotCover, Visual Studio 2013, 2012, 2010 and 2008 Code Coverage files.
- Dependency Graph
- Dependency Structure Matrix
- Visualizing Code Metrics
- Validating Code Rules
My team and I use Typemock's Isolator. It's a unit testing framework with some nice features, one of them is code coverage. We are very satisfied with this product.
I would like to suggest one more tool.
Fine Code Coverage Its small simple and 100% free. https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage
Disclaimer : I'm the primary developer
- Coverage levels up to MC/DC and MCC
- Compare coverage delta between tests
- Calculate optimal test execution order
- Pre-commit and post-commit patch analysis
- Supports C++ and C in addition
- 300 Euros per licenses. Available in batches of five.
(Disclaimer: I'm working for the vendor of above tool)
-
1Please disclose your affiliation with Squish Coco. – RockPaperLz- Mask it or Casket♦ Feb 3 '18 at 3:11
-
And also name the pricing conditions. If I'm not mistaken, this one doesn't come for free. – Izzy♦ Feb 3 '18 at 10:35