Mocks have become part of the culture in all professional teams today. Used wisely, they allow fine-grained testing of functionality to reach a high-level and high-quality test coverage, granting you comfort to refactor and evolve your code. Used carelessly, mocking can lead to fragile tests, cause terrible headaches to dev team and end up slowing you down and impeding refactoring.
This video course is for developers that have used mocks for a while in real-world projects, but despite being comfortable with the mocking API, are still looking for ways to use them effectively on the long run.
This is the recording of a 3.5 hours live webinar that took place in October 2021.
Note: After watching the recording you can ask me any question you have via email.
Agenda
- The Good parts: decoupling, isolation, speed
- The Bad parts: fragile tests, inconsistencies, and impossible test cases
- Mock Roles, not Objects priciple
- The Command-Query Separation Principle
- Functional Core / Imperative Shell segregation
- Alternatives to Argument Captors
- Mocking time - 4 techniques
- Why and How to avoid Partial Mocks
- Mocking vs External Libraries/APIs
- Is mocking statics bad? Exceptions
- When should we prefer a Fake implementation over a Mock
What to expect?
More than 2/3 of the time we code, refactoring and discussing tradeoffs of different usage patterns of mocks, stubs and fakes. When the discussions raises to the higher-level design, they are summarized in slides that you can later use as reference.
The coding happens in Java, but the discussion can also be followed by natives of other languages, like PHP, JS, C#,...
After following this workshop you’ll acquire solid knowledge about the best practices of using mocks, and learn how to write tests that are easy to maintain. Alongside you'll discover how to listen to what your unit tests are trying to tell you, and this way foster one of the most important sources of feedback about the design of your production code.
After the purchase you will get: the video recording, all the slides, and the code zipped together with Git commit history.
This Training is for you because:
- You wrote or fixed hundreds of tests using mocks and you felt that those tests were too fragile, and not very helpful.
- You want to lay the correct foundation for unit testing a new project you are about to start.
- You want to listen to your tests to improve the design of your production code.
Prerequisites:
- Strong knowledge of the core features offered by mocking frameworks (eg. Mockito)
- Wrote at least 100 tests using mocks.
- Enthusiast about software design.
Prep-work:
- To strenghten your knowledge of the mocking features, you can watch the following introductory video: https://www.youtube.com/watch?v=A4Oq9oSpqD0
- If your skills are a bit rusty, try to solve in advance the Prep-Assignent in the resources below (mocking-prepwork.zip).
- As a follow-up, there's another 'Assignment' to tackle after watching the video.
Technical Requirements
I would recommend you get yourself a black coffee and pay close attention to the discussion, stop the recording at any moment, debate the ideas with your colleagues and perhaps try to reproduce my coding on your own machine. Next to the video you can download the code zipped together with the git history, so you can explore my commits if you get lost.
To run the project you will need a Java 8+ SDK installed, a decent IDE, and access to GitHub and Maven Central.
Course Curriculum
Trainer: Victor Rentea
Victor Rentea is a Java Champion, Associate Professor and Technical Trainer writing code for over two decades in many languages.
He is training developers since 2012, having developed an extensive curriculum that covers most of the software engineering best practices and typical Java-stack development. You can read dozens of recommendations from the developers he trained on LinkedIn and on victorrentea.ro.
Victor is best known for the energy of his talks, many ranked among the best at their conference. You can expect a similar style here, explaining complex concepts in simple, easy-to-remember terms.
Get Access
Frequently Asked Questions
How long do I have access to the course?
How does lifetime access sound? After enrolling, you have unlimited access to this course for as long as you like, across any and all devices you own.
Can I get an invoice for my company?
Payments are handled by Onelink, Stripe's reseller, which emails you the receipt. For a company invoice, contact Onelink starting from that receipt email.
I bought this course on Teachable. Do I pay again?
No. Every Teachable purchase was carried over: get your access link with the email you used there.
