vendredi 13 octobre 2017

Refactoring a method so it doesn't query the database to be more easily testable?

I have the assignment of doing our code more testable and there are methods that apply bussiness logic that rely on database values, some queries don't even happen given certain values.

Some of these methods need several repositories so mocking them up creates a really long setup in the unit test, so one solution I came up with is refactoring these methods so instead of querying objects/values from the database, these go as parameters of the method.

Is it wrong to do this? is there another solution that I don't see/know?
Please let me know.

Aucun commentaire:

Enregistrer un commentaire