DEV Community

Discussion on: What are your biggest problems with unit testing?

Collapse
 
sharpdog profile image
SharpDog
  1. Adding lots of unit tests makes refactoring difficult
  2. Unit testing code bound to GUI elements (e.g. property change events)
  3. Internal and private methods/classes
Collapse
 
miniscruff profile image
miniscruff
  1. Unit tests should provide a base line to prevent regressions when refactoring. If your tests are causing issues than your are refactoring wrong. See the book on refactoring by Martin Fowler.
  2. Your UI framework should provide these methods. This is usually referred to as integration testing tho
  3. Many methods of testing these like subclasses or testing through the public ones.
Collapse
 
teachingtls profile image
teachingtechleads

Can you define what you mean by "refactoring"? Because the point of unit tests are to prove that your refactoring was completed successfully.
Given that the test passes initially, when you refactor the implementation, then the test should still pass. A refactoring doesn't change the implementation, it just enhances it.

Collapse
 
sandordargo profile image
Sandor Dargo

Most probably he means that the tests are strictly coupled with the production code implementation. Tests are exercising the implementation in a given moment, not the API, the behaviour. Seems like the problem of Test contra-variance.

Collapse
 
thinkdigitalsoftware profile image
ThinkDigitalSoftware

I get what he means. If you change something you believe to be inconsequential, your tests will ensure that. However, if you update a function and change its output and forget to fix a particular function, tests will make your mistakes evident.