back

by pwim·15y ago·view on hn ↗
It sounds like the issue is with how you are writing you tests. For instance, you state "refactoring breaks a lot of test cases". As the normal TDD cycle is test-code-refactor, refactoring shouldn't break your tests. Without seeing your actual code, it is hard to give you advice, but it sounds like your test cases are too coupled with the internal workings of your code, rather than testing the interface.
1 comments
While refactoring, it's always the unit tests that break. Maybe instead of having a (Rails) scope on a child class, I move that to a method on the parent class. The integration tests don't know about the models, and the exact same results are returned. But all my unit tests are haywire because they were testing the models.
If your refactoring causes test code to break, then it also causes "real" code to break, yes? All code using that interface needs to be fixed appropriately, which can typically be done with automated tools.

If there's no corresponding production code using the same interface, you have a problem: you're probably testing at the wrong level.