Angular recommends using Jasmine for their testing framework, but the more I work with Jasmine the more I worry about the fragility of my unit tests. Currently, I am using stubs and spies to provide dependencies to the functions, but I am worried about how the tests will behave when functionality is added to the codebase.
For example, when making spies using dependency = jasmine.createSpyObj(['method1', 'method2'])
, calling dependency.method3() when implementing a new feature would cause the tests to fail because method3 does not exists on the spies.
The same applies if I use stubs as described in the angular guide, as I would need to create stub functions using jasmine.spyOn or similar methods.
Ideally, this case should not result in failure and makes my tests incredibly fragile. I can resolve this by mocking the entire class interface, but this is unideal.
Is there any way of avoiding this?
Aucun commentaire:
Enregistrer un commentaire