Question: Why is unit testing harder in OOP than functional programming?

  1. Objects may maintain internal state, which is not easily accessible by the tests.
  2. The quality of unit testing frameworks for functional languages is better.
  3. OOP promotes code reuse, which means that your tests have to consider more use cases.
  4. Object-oriented languages tend to rely on frameworks such as Spring or Hibernate, which make them difficult to test.

Answer: The correct answer of the above question is Option A:Objects may maintain internal state, which is not easily accessible by the tests.