I want to set a build failure condition for unit test cases build runner using NUNIT and DOTCOVER.
My requirement is, If any developer commits the code without test case, build should fail. Even they commit just 2 lines of code.
So I tried to set build failure using STATMEMET Coverage options, but it doesn’t work for some scenarios.
Rules I set, “Fail build based on metrics changes compare to last successful build , if percentage is dropped less than 0.001“ and 0.001 is just added 2 lines of code.
Above rule works perfectly fine for most of the scenarios, but below situation it doesn’t work
Build No: #5
Statement Coverage: Covered Lines/ no of Lines => 65/268= 24.253 %
Developer 1 committed the code without adding any test cases, and TC automatically triggered the build
Now, Build No: #6
Status: Failed (because Statement coverage ratio is dropped by 0.179)
Statement Coverage Ratio: 65/270=24.074 % (Dropped by 0.179 hence build failed)
Now developer 1 is writing test cases mean time Developer 2 committed the code with more test cases and triggered the build( note : Developer 1 still writing test case not yet committed)
Now, Build No: #7
Statement Coverage Ratio : 70/272 = 25.735 %
Here is the issue According to my failure condition, TC compared current Statement coverage ratio with last successful build Statement coverage ratio ( BUILD NO # 5 – 24.253 < BUILD NO #7 – 25.735) and got passed the current build even BUILD No 6 doesn’t have any test cases.
I don’t know How do I handle such a situation?, Do you know any different ways to achieve my requirement .
This kind of conditions are really more helpful to do some preliminary validation for TDD approach whether team is following or not.
Thanks for your patience .