MartinBruun / P6

2 stars 0 forks source link

(app) Create a similar firstBooking, firstMachine, etc. structure on the app side to standardize testing #269

Open MartinBruun opened 2 years ago

MartinBruun commented 2 years ago

What should be improved upon and why? Because there is alot of boilerplate code in the tests to setup the different models (with different forms of injection and setting of values), it would be better to have a standardized way of having some fixtures that "just work" and are tested that they do indeed have proper default values (as in web)

How do you see it can be improved? Option 1 might be to have the same structure as in web which would be "firstBooking" and "secondBooking" that are hardcoded. Ie. firstBooking has firstService, firstAccount and firstMachine in it by default.

By doing this, if there are some specific tests that need that firstBooking and secondBooking point to the same account for example, it can just be specified as the important thing in the test by overriding the values, whereas now it is almost impossible to see what is the "important" thing that is under test (right now all the boilerplate is not important. TBH i think most of our test simply tests "Booking()", but that cannot be done right now that simply)

Option 2 might be to make "factory" functions, although i personally would advice against it, since it just further abstracts something which should be simple (ie. it is easy to test whether a specific firstBooking is valid. But how do you make sure that all possible permutations of a createBooking function is valid?)

Option 3 might be to research how flutter itself avoids the use of expliciting boilerplate that is outside of what the test is testing.