vendredi 4 décembre 2015

Unit Test Internal Optimization Logic with TDD

How do you unit test internal optimization logic which doesn't change the public behavior of a class but is complicated enough where you want to make sure it's working?

For example, say I have a class FooStore which has insert(Foo foo) and getByProperty(Property) methods.

If you're doing test driven development, you would first write some failing insertion and retrieval unit tests, then code FooStore until the tests pass.

What if you realize later on that you can build some internal data structures in FooStore so that insertion or retrieval is much faster. But since there's no change to the behavior of insert or getByProperty, how would you write a failing unit test first? And how would you write tests that ensure the new logic is actually performing faster?

Aucun commentaire:

Enregistrer un commentaire