Test coverage

Test coverage

Made by DeepSource

Unexecuted code detected in test TCV-002

Coverage
Major

Test code has lines of code that were never executed during the test. This can happen when you've written test for some application logic which is never hit during the tests.

If you're doing TDD (Test Driven Development), this could be a result of a use-case that you forgot to handle. Another reason could be the presence of dead code in your tests, which you should refactor and take action on.

It is strongly recommended to review the occurrences and make sure your're not missing anything.

Example

Let's assume thet we are making a pattern generator that only generates hexagons and circle. Below is a test for the generator:

def test_pattern_generator():
    '''Make sure that the pattern generator is accurate.'''
    data = "This is intentionally kept constant for this example."

    match pattern.name:
        case circle:
            assert pattern_is_circle(pattern.ascii)
        # This would never be hit, because you forgot to implement it.
        case hexagon:
            assert pattern_is_hexagon(pattern.ascii)
        case triangle:
            assert pattern_is_triangle(pattern.ascii)

    if not data:  # Dead code block, since data is a constant and always Truthy.
        pattern.generate()  # This line would never be executed.