Unit Testing - what does "unit" mean there? Is it a public method? A class? 2 classes? No. It's a "unit of behavior" says Kent Beck, the author of JUnit and inventor of Unit Testing. It's the thinnest slice you can isolate from a full feature, ideally end-to-end. On the other hand, it's easier to write fine-grained tests covering a single method or a class, but they won't provide you the same degree of safety as larger end-to-end automated tests. That's why we should aim to to cover as much code possible with isolated, repeatable and reasonably fast tests, while also keeping them simple and maintainable. But that's hard. It's one of the most difficult task for any developer, no matter how experienced.


After discussing unit testing for hundreds of hours in dozens of companies, I found that the biggest challenges for most teams is to identify the risks in their code, and then to master the testing tools to cover that code with simple, effective tests. Tests that really help you catch bugs and save you time, while not impeding future refactoring. During this course you will learn techniques to bring more of your application under tests by making best use of the Spring Framework's testing support.


This is the recording of a 4-hours live webinar that took place in September 2020 with 26 live participants. The content is extremely dense, mixed with explanations of how the Spring Framework works internally.


Agenda

During this training you will learn:

  • Best ways to test flows interacting with a relational database: external, in-memory and running in a local Docker
  • Test-driving dynamic queries underlying search forms (TDD), and using a .feature file approved by business (BDD)
  • Best practices when testing with files, nosql or other non-transacted resources: when/how to clean-up
  • Using a fake test implementation
  • The problem with caches
  • How to control time from your tests
  • Best ways to test flows calling external services: @MockBean vs WireMock (file-based or programatically)
  • Testing your REST API: should you? and how?
  • Black-box testing in-JVM: emulated HTTP calls and embedded Spring Boot server
  • Black-box testing your application deployed in a local Docker
  • JUnit 5 features that help you keep your integration tests clean

Every single technique we cover can run on your CI Jenkins pipeline!


What to expect?

During the training we write automated tests for 3 simplified examples of production code, for each one trying out and comparing various testing strategies. Below you can find a diagram summarizing all topics covered in detail.

Each working alternative was carefully committed to a git that you will get access to. Even if it's 90% code, the discussion insists on principles, best practices and pitfalls of the solutions we implement, and acknowledges that you can google up additional details afterwards about the deeper topics we touch upon (Docker, WireMock). After watching the video, I will insist you ask me any kind of question you have related to what we covered.

After following this course, you'll take away at least a dozen of key practical techniques that you can immediately apply to your day-to-day work. Expect an intense but entertaining experience, as usual!


Target Audience

Java developers with prior contact with Spring Framework, or otherwise extremely eager to learn it. Basic knowledge of a mocking framework (like Mockito) is also useful.


Technical Requirements

To be able to run the code locally, your machine should have a Java 11+ SDK installed, Docker, and access to Maven Central. If you want to directly replicate my actions, download and install IntelliJ Community Edition, as I occasionally used some of its specific features.

After purchase, besides video recording and slides, you will be able to download the final code zipped together with the git history, allowing you to browse through the commits at your own pace.


Further Reading

Here are some resources you could use to learn more about the techniques we use in the training:


P.S.: The content is distilled from my 2-days (16-hours) Unit Testing training. If you are interested in a private dedicated session for your company, please find here my entire curricula and contact details.


Below is a master overview of all that we cover in the course. The blue arrow denote the tests we wrote and the red rectangles are the techniques we used:

Trainer: Victor Rentea

​Victor Rentea is a Java Champion and Associate Professor at UPB writing code for over two decades in many languages.

Since 2012 he is coaching and teaching others on day-to-day coding topics, having developed by now an extensive curricula that cover most of the software best practices and typical Java-stack development. ​Today, over 40 companies bring him in for consultancy or training sessions. Thousands of developers and students have attended his classes by now and left him many recommendations on LinkedInFacebook, and on victorrentea.ro.

Victor is best known for the enthusiasm and depth of his talks, which you can also enjoy during his courses and webinars. To share his passion for Clean Code and Unit Testing, he founded the Bucharest Software Craftsmanship Community, one of the largest developer communities today in Romania.

Choose a Pricing Option

Frequently Asked Questions


Can I get an invoice for my company (VAT-free)?

To add the VAT code of your company to the checkout page and remove the VAT taxes, follow these simple steps.


Can I ask questions after I watch the recording?

PLEASE DO! Email me your questions, no matter how silly or complex you may think they are. I'd be glad to help, so don't hesitate to contact me.


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.


What if I am unhappy with the course?

We would never want you to be unhappy! If you are unsatisfied with your purchase, contact us in the first 30 days and we will give you a full refund.


Can I have this training for more of my colleagues?

There are two ways I can help you:

  • For 5+ developers, contact me for a discount and a company invoice
  • For 10+ developers or for a longer in-depth session, contact me for a dedicated webinar for your company.