Test coverage

Test coverage

Made by DeepSource

Branches not covered in tests TCV-003

Coverage
Critical

Test code does not cover certain branches, indicating that there are no tests written for those specific branching conditions. This can lead to potential bugs or unexpected behavior going unnoticed, as the untested branches may contain logic that has not been verified.

It is important to ensure that all branches in the code are covered by tests to guarantee proper functionality and identify any issues that may arise. Review the code and add tests for the untested branches to increase test coverage.

Example

Consider the following Ruby code snippet:

def calculate_discount(price, discount_code)
  if discount_code == "SUMMER"
    return price * 0.1
  elsif discount_code == "WINTER"
    return price * 0.2
  end
end

In the above code, there are two branches based on the discount_code. However, if there are no tests written to cover both branches, it means that the behavior and correctness of the code under those conditions are not being verified. To fix this issue, you should add tests that cover both branches of the calculate_discount function:

def test_calculate_discount
  assert_equal 10, calculate_discount(100, "SUMMER")
  assert_equal 20, calculate_discount(100, "WINTER")
end

By adding tests for both branches, you can ensure that the code behaves as expected and that all possible scenarios are covered.