jeudi 2 avril 2015

How to test when code is dependent?

For example I have a function which sets some data and another which gets the data (the output is not the same as the one that has been set previously).


Now unit tests says that you have to test only one feature at the time. So let's test the setClass method. In order to know if the setClass works I need the getClass and getStylesString method.


I would not go into checking whenever the internal data has been saved correctly because the test should not care about the internal working of the module, but only the public API.


Notice that the classes have an internal id which is returned in the getClass so there is no way to know or expect a certain id.


So how should I structure the tests? I should only test the getClass?


Code: http://ift.tt/1wnEuZC


Aucun commentaire:

Enregistrer un commentaire