1.

What are some of the best practices to be followed while writing code for making it more testable?

Answer»

Following are some of the best PRACTICES that can be followed while coding to make the CODE more testable:

  • Make USE of interfaces as a wrapper to IMPLEMENTATION classes. This helps testers to replace the class with mocks or stubs to TEST the module.
  • Use dependency injection wherever needed instead of creating. new objects. This makes it easy for testing individual modules and also supply dependency in the test configuration.
  • Avoid using static methods as that makes it difficult to test because they cannot be called polymorphically.


Discussion

No Comment Found