Unit Test Conventions for Code Coverage

The normal convention for naming the unit test is to name it same as the class which we are going to test and append it by the word ‘Test’ to it.

For example:

Model Class:
class Abc {


}

Test Class:
Class AbcTest {


}

In the test class, if we can have a property testing class that points to the class, we are testing, it will be helpful in code coverage. AbcTest might be intended to test only the class Abc but internally it can call many other classes and their methods which may not be necessary for getting the code coverage numbers. Hence the better way to do is

Test Class:
class AbcTest {
testingClass = ‘Abc’;


}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s