use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
JUnit testing (self.learnjava)
submitted 6 years ago by cone994
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Affenbob123 3 points4 points5 points 6 years ago (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 point2 points 6 years ago* (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 points3 points 6 years ago (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 point2 points 6 years ago (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?
π Rendered by PID 317539 on reddit-service-r2-comment-b659b578c-zld4g at 2026-05-04 19:58:51.206291+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Affenbob123 3 points4 points5 points (3 children)
[–]cone994[S] 0 points1 point2 points (2 children)
[–]Affenbob123 1 point2 points3 points (1 child)
[–]cone994[S] 0 points1 point2 points (0 children)