Fundamentals of Code coverage.

Code coverage:

verification metric(formula) of determining how many line of code in a given binary(DLL) are measured when run test cases against it.

Can figure out how many how much code has been tested for the specified test method.

Can judge how well the code/function is tested.

Do not tell how well code is written.

Metric for functional testing.

Implementation Example:

Add a utility Function for determining positive number.The function logic have a If and else block code inside.

Add Utility reference to a console application.

Add Unit test Project.

Run Test ctrl + R,T

VS Tab —> Test–> Analyze Code Coverage –> Selected Tests

In Code coverage Result  Window –>> Show Code Coverage Coloring

Light Red — Not covered.

Case Could be either if/else condition block not covered.

Help to identify unreachable code.

Help to investigate gaps in testing.

Identify redundant test cases.

Leave a Reply

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

You are commenting using your 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