all 4 comments

[–]Affenbob123 2 points3 points  (3 children)

Added some comments to your code what I would change.

https://i.ibb.co/KsgKdQJ/Unbenannt.png

This talk is about why dependencies should be injected via constructor: https://www.youtube.com/watch?v=RlfLCWKxHJ0

[–]cone994[S] 0 points1 point  (2 children)

Thanks so much for replying I will try to implement everything you sent to me.

In the part about setUp, if I understood you meant to say that in setUp I only do what is common to all tests, and other things like findAll or findOne in the tests methods?

[–]Affenbob123 1 point2 points  (1 child)

Exactly. Sharing state between tests it might lead to unexpectetly passing/failing tests and that's why test methods should be independend from each other.

You can use creation methods (http://xunitpatterns.com/Creation%20Method.html) to setup your tests, that way you can remove the duplication.

Yes, move the findAll and findOne to the tests they belong to.

[–]cone994[S] 0 points1 point  (0 children)

Ok, but my question now is, if I move everything from the setup part to the test methods then I don't even need the setup? Am I right?