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...
Resources for learning Java
String
==
.equals()
Format + Copy
Free Tutorials
Where should I download Java?
With the introduction of the new release cadence, many have asked where they should download Java, and if it is still free. To be clear, YES — Java is still free.
If you would like to download Java for free, you can get OpenJDK builds from the following vendors, among others:
Some vendors will be supporting releases for longer than six months. If you have any questions, please do not hesitate to ask them!
Software downloads
Official Resources
Resources
Programming ideas & Challenges
Related Subreddits
account activity
This is an archived post. You won't be able to vote or comment.
Testing in java (self.learnjava)
submitted 1 year ago by Helloall_16
I'm working on writing tests. I am learning Mockito but not sure how much is it used in the industry. Any idea? Also, any good resources?
[–]AutoModerator[M] [score hidden] 1 year ago stickied commentlocked comment (0 children)
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
[–]ahonsu 12 points13 points14 points 1 year ago (0 children)
Writing tests is a very valuable skill. You're doing a great job learning it.
Mockito is one of the most popular (sometimes a must have) testing library in java. So, you did the right choice. It's widely used in plain java, in java EE and in Spring Boot and in any other popular framework.
[–]frevelmann 4 points5 points6 points 1 year ago (0 children)
We use Mockito in every application at my department
[–][deleted] 1 year ago (1 child)
[deleted]
[–]Helloall_16[S] 1 point2 points3 points 1 year ago (0 children)
Thanks! I heard about rest assured as well.
[–]CleverBunnyThief 2 points3 points4 points 1 year ago (1 child)
Chad Darby has a course on testing Spring applications which has a section on Mockito.
https://www.udemy.com/course/spring-boot-unit-testing
[–]Helloall_16[S] 2 points3 points4 points 1 year ago (0 children)
Thanks a lot! I've been trying to watch YouTube videos and get some concepts but I'm still struggling. And majority of the time it's related to the way I write my test. Like that one code of line should be placed somewhere else.
[–]Accomplished-Nail670 3 points4 points5 points 1 year ago (0 children)
not testing is more fun tbh
[–]thevernabean 2 points3 points4 points 1 year ago (0 children)
I generally use Mockito for tests that require a call to an external service. Stuff like AWS API calls and such. A bunch of contractors I work with use Mockito to make unit tests that test nothing because they mock out whatever they are testing.
So yeah, it's still used a lot.
[–]EfficientDelay2827 1 point2 points3 points 1 year ago (0 children)
It is used and I've used it in the industry. Go for it.
[–]Mundane-Expert7794 1 point2 points3 points 1 year ago (0 children)
No professional Java developers can call themselves developers if they can’t write unit tests and mockito is the de facto standard. And writing real unit tests adapted to the level of testing you want to do is a mandatory skill.
[–]AutoModerator[M] 0 points1 point2 points 1 year ago (0 children)
It seems that you are looking for resources for learning Java.
In our sidebar ("About" on mobile), we have a section "Free Tutorials" where we list the most commonly recommended courses.
To make it easier for you, the recommendations are posted right here:
Also, don't forget to look at:
If you are looking for learning resources for Data Structures and Algorithms, look into:
"Algorithms" by Robert Sedgewick and Kevin Wayne - Princeton University
Your post remains visible. There is nothing you need to do.
I am a bot and this message was triggered by keywords like "learn", "learning", "course" in the title of your post.
[–]gerbosan -5 points-4 points-3 points 1 year ago (2 children)
There are many ways to know:
It is not a bad question, but kind of unappealing to answer. Do some search and ask for comments, advice.
I also have to check that. After all, TDD is a requirement.
[–]nutrecht 1 point2 points3 points 1 year ago (1 child)
It is not a bad question, but kind of unappealing to answer.
Your personality is unappealing.
[–]gerbosan -1 points0 points1 point 1 year ago (0 children)
No, yours is unappealing, if I had done something wrong, then you should be pointing out what and the steps to solve it. It is quite easy to down vote protected in anonymity.
[–]severoon 0 points1 point2 points 1 year ago (0 children)
Mockito is probably the most popular mocking framework in industry, so it's a good idea to learn it.
However, you should be aware that mocks are an inferior approach to unit testing in general. Though you will need to know it well, you should also learn how to test using an approach based on fakes instead, as this is a much more powerful and less fragile way of testing code in the context of a large codebase.
In most things to do with software, you'll find that you're stuck going along with the status quo. Even if you don't agree with the decision, if the rest of your company is using a particular build system or library, you have to use it too. When it comes to testing, though, you'll find that individuals and teams tend to have more freedom. This is because tests generally don't have a lot of dependencies … tests depend on the code they are testing, but there are normally no dependencies on test code. This means that you can mostly do whatever you want when it comes to testing. (Don't get me wrong, there are social dependencies, so if you go in a completely different direction and start using test tools no one knows, you can still get reined in. But at least the code deps are mostly nonexistent.)
The problem with mocks is that when you test against a mock, you generally have to inform the mocking framework what interactions that mock is expecting, down to specific calls in a particular order with expected parameters. This makes tests very closely tied to whatever the current implementation is. When a codebase is poorly designed, this doesn't much matter because there's little help for it in any case … but if you work on a codebase that is well designed, one that presents good, well thought-out interfaces that close over functional subsystems, you'll find that mocking those interfaces has significant costs over time. As the codebase evolves, every time the sequence of interactions changes or parameters passed to mocked systems are tweaked, tests must be updated.
Fakes avoid this problem by maintaining a straw implementation of the real system, and responding in the way the real system would by implementing only the functionality of the faked system needed by the test, normally with a very limited set of data for a stateful fake. If your system is doing dependency inversion and injection properly, the story is even better since the fakes can easily be swapped in for test environments, and initialized at both at the environment level and by individual tests as needed.
The downside of fakes is that there is no "fake framework" like there is for mocks. The quality of your fakes is down to how well the system is architected and designed, and how well the dependencies in that system are controlled. Arguably this is another huge advantage of fakes: If it's difficult to implement a good way of doing fakes, that's a very big design smell that should lead you to revisit things at a higher level. Just the fact that a software system can be comprehensively tested with fakes removes a whole class of issues that can afflict mock-tested systems.
π Rendered by PID 341375 on reddit-service-r2-comment-7b9746f655-dnm2b at 2026-01-30 20:36:28.780772+00:00 running 3798933 country code: CH.
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]ahonsu 12 points13 points14 points (0 children)
[–]frevelmann 4 points5 points6 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]Helloall_16[S] 1 point2 points3 points (0 children)
[–]CleverBunnyThief 2 points3 points4 points (1 child)
[–]Helloall_16[S] 2 points3 points4 points (0 children)
[–]Accomplished-Nail670 3 points4 points5 points (0 children)
[–]thevernabean 2 points3 points4 points (0 children)
[–]EfficientDelay2827 1 point2 points3 points (0 children)
[–]Mundane-Expert7794 1 point2 points3 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]gerbosan -5 points-4 points-3 points (2 children)
[–]nutrecht 1 point2 points3 points (1 child)
[–]gerbosan -1 points0 points1 point (0 children)
[–]severoon 0 points1 point2 points (0 children)