
Install the latest JDK, download it from Oracle, install Spring Tool Suite for Eclipse, and configure STS to use the Java SE JDK home directory.
Kick off this JUnit and Mockito crash course by exploring its sectioned structure and startup setup, enjoy self-paced quizzes for self-check, then practice writing unit tests and asking questions.
Master unit testing by validating public methods with varied inputs, handling positive and exception scenarios, and using JUnit with Mockito to mock dependencies for fast, isolated tests.
Maven automates building, testing, packaging, and deployment of Java projects using convention over configuration, with a standard folder layout (src/main/java, src/main/resources, src/test/java, src/test/resources), archetypes, and IDE support.
Create a maven project in Eclipse, add JUnit 5 dependencies (JUnit Jupiter engine and Vintage engine) to pom.xml, set the compiler to 1.8, and migrate tests to JUnit 5.
Build a Maven project, run tests automatically, and generate a jar in the target directory. Run Maven install to compile sources, execute tests, and produce artifacts with sure fire reports.
Download and unzip the order processing service, import as a maven project in Eclipse, configure pom.xml dependencies for JUnit 5 and Mockito to test the bo and dao layers.
Learn how mocking enables unit testing by isolating a unit from its dependencies, using mock objects, stubbing, and verifying with Mockito. Follow the three steps: stubbing, setting expectations, and verifying.
Learn how test coverage measures which source lines are executed by unit tests, identify gaps, and use tools like JaCoCo, Cobertura, and EclEmma within CI pipelines.
Explore how Mockito matchers simplify stubbing and verification, using any int and other matchers to handle inputs without creating full objects.
Set up the Mockito scrapbook Maven project in Eclipse, import JUnit and Mockito dependencies, and prepare to test class A by mocking B’s void method.
Learn the F.I.R.S.T principle for agile software testing, ensuring fast, independent, repeatable, self-validating, and timely unit tests to deliver quick feedback across environments.
Explore partial mocking with a Mockito spy to reuse real methods while stubbing selective behavior, including using doReturn with a spy and contrasting with when, in a practical list example.
Understand spy versus mock in Mockito: spies use the real object unless stubbed, while mocks are library objects, and use when syntax to stub or call real methods when needed.
Download the Maven project, import it into Eclipse, install Tomcat 9, run the simple Java web app with a coupon servlet, two jsp pages, and JUnit/Mockito tests.
Create unit tests for a servlet by mocking http servlet request, response, and request dispatcher with Mockito, generating doGet and doPost tests and running them as JUnit tests.
Update existing tests to use parameterized values, mark the test class with the parameterized runner, and verify multiple data sets yield expected results, showcasing parameterized testing in JUnit.
Sample of the reviews:
Very good teacher, knows the material. Hands on exercises that are quick to write, but very useful to support the learning of the course content. I'll keep these tiny projects and I'll refer to it often when coding. I've learned a lot about JUnit testing and Mockito, but also about other tools useful in software unit testing: Ex: Spring, shortcuts in Eclipse. - Guy Audet
Very well explained, to the point, on short interval to grasp the content. Every lecture has purpose achieved. Simple examples. Really nice course. - Kaushal Trivedi
I enjoyed the course. The Course is well structured, principles were clearly explained, the sound and picture quality was good. I recommend the course to everyone who would like to begin with java unit testing. Thanks, Bharath! - Mario Banay
---
Are you a java developer who want to become an expert at Unit Testing ? Then this course is a quick practical guide for you. Learn how to write real unit tests using JUnit and Mockito. This course will simplify things with concepts and step by step implementations .
There are so many java professionals who write great code , but not unit tests. This course aims at filling that gap by covering JUnit and Mockito the two required frameworks to write good unit tests.
Learn and master the most popular unit testing technologies in this comprehensive course.
Understand the importance of writing Unit Tests
Updated to use the latest versions of JUnit and Mockito
Learn the Syntax of JUnit 4 and 5
Demystify the topics of Mocking
Write Unit tests using JUnit and Mockito
Learn what test coverage is and how to measure it
Run unit tests as a part of your Maven build
Learn how to Unit Test Spring Boot Applicaiton
All in easy steps
Mastering Unit Testing for Java Professionals:
JUnit is a open source Framework to test and assert code behavior . Mockito mocks out the dependencies and stub the expectations allowing testing a particular layer/unit in isolation.
Any java developer at any level can access the key lessons and concepts in this course and learn to write quality unit tests.
This course is perfect for every java developer who works on building high quality applications .
Contents and Overview:
In over 4 hours of lectures this course covers necessary JUnit API and its usage with Mockito.
This course covers the importance of unit testing , how to effectively use JUnit ,how mocking works and how to use Mockito to write real unit tests.
Up on completion you will be able to test Java and Spring Boot applications ,run unit tests as a part of your build and measure code coverage and improve it.