This is no holy grail of acceptable code coverage.   Add all the 
indirection, dependency injection and mocking, and you aren't going to get 
to 100%.   Even more, you probably shouldn't get to 100%

Would you unit test the following class? 

public class MyClass
{
        private string someVariable;

        public string SomeVariable
        {
                get { return someVariable; }
                set { someVariable = value; }
        }
}

I've seen people write tests like the following

[TestMethod]
public void ShouldCreateNonNullMyClass() 
{
          MyClass instance = new MyClass();
          Assert.IsNotNull(instance);
}

The same goes with testing the getter/setter.  That is just plain silly to 
test, and a waste of time.   Same goes with generated proxy code.  At some 
point you start unit testing the CLR or the proxy generator tool.   You 
should be more worried about having good coverage in places that you are 
refactor or fixing a bug. 

Also, set a baseline.   Ask questions when your coverage goes lower from 
the previous build to the current. 
You should look at places that have low code coverage and ask yourself if 
they are candidates for breaking up into smaller classes, using interfaces 
and dependency injection along with mocking in order to drive up the test 
coverage. 

If your proxy code constitutes 25% of your code base, then setting your 
goal at 90% probably isn't realistic.  You shouldn't worry about getting 
100% coverage of your proxies unless you feel that your deployments aren't 
going well, and want to run functional/integration tests after your 
(automated) deployment. 


Regards,
Troy Gould
Sr. Consultant
ThoughtWorks






Pieter de Bruin <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED]
09/05/2007 03:40 AM
Please respond to
[email protected]


To
<[email protected]>
cc

Subject
[OzTFS] Actual code coverage results and proxy files






Hey all,
 
We are trying to get best possible results out of code coverage. It looks 
like this is getting a long nicely, but we're struggling with generated 
code and web service proxies in particular.
 
I've read that code coverage metrics aren't the holy grail [1] and that 
you can put generated code in separate projects [2].
 
Is that also your opinion? Do you have a better way of working normally 
with proxy classes and still get acceptable code coverage results?
 
Thanks,
 
Pieter
 
[1] 
http://blogs.msdn.com/bharry/archive/2007/05/07/managing-quality-part-7-code-coverage.aspx

[2] http://geekswithblogs.net/sbellware/archive/2005/05/01/38845.aspx
OzTFS.com - to unsubscribe from this list, send a message back to the list 
with 'unsubscribe' as the subject. View the web archives at 
http://www.mail-archive.com/[email protected]/
Powered by mailenable.com - List managed by www.readify.net 



OzTFS.com - to unsubscribe from this list, send a message back to the list with 
'unsubscribe' as the subject. View the web archives at 
http://www.mail-archive.com/[email protected]/
Powered by mailenable.com - List managed by www.readify.net

Reply via email to