Code coverage is to determine to what portion of your project code is being tested by Unit testing; you can use the code coverage feature of Visual Studio.

Code coverage is an option, when you run the test methods, using Test Explorer.

Analyze code coverage on unit tests in Test Explorer.

On the Test menu, choose Analyze Code Coverage.

Analyze code coverage Image 1: Analyze code coverage

Code Coverage Results

Code coverage results

Image 2: Code coverage results

Test Method

Test method
Image 3: Test method

Actual Method

Actual method
Image 4: Actual method

Discussion on Code Coverage %

When any programmer starts writing the Unit testing, he will have one question in mind -- how much we need to aim for code coverage percentage. Thus, he will go and keep on asking his Manager about code coverage percentage.

Below is the discussion that happened between programmers and the manager about the code coverage percentage.

Code coverage discussion
Image 5: Code coverage discussion

One programmer (programmer 4) observed these conversations and approached the Manager

Conclusion

You should focus on writing good unit test cases instead of focusing on the code coverage percentage.