Tests that are 2-3 times bigger than the testable code

You might be testing the wrong thing – you should not have different tests for every method in your code.

You might have too many tests because you test implementation and not functionality – try testing how things are done test what is done.

For example if you have a customer that is entitled to get a discount on every order – create a customer with the correct data and create an order for that customer and then make sure that the final price is correct. That way you actually test the business logic and not how it’s done internally.

Another reason is for big tests is lack of Isolation (a.k.a mocking) if you need to initialize difficult objects that require a lot of code try using fakes/mocks instead.

And finally if you have complicated tests it might be a smell – if you need to write a lot of code to test a simple functionality it might mean that your code is tightly coupled and your APIs are not clear enough.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)