
Set up the java development environment by installing the java sdk 17 or 11, maven, and IntelliJ IDEA community edition, then create a demo java application and run.
Explore basic software testing by creating a Java Maven project, configuring JUnit 4, Hamcrest, and writing your first unit tests with assertions to verify expected results.
Debug unit tests by adding a score-range method and testing various score inputs with assertions. Use the test annotation, breakpoint, and the debugger to explore results and boost test coverage.
Improve test coverage in tdd with JUnit4/JUnit5 by running unit tests, reviewing the coverage report, and adding tests to cover all methods and conditions, including exception scenarios and assert throws.
Explore unit test principles such as isolation, independence, and repeatability. Learn a three-step pattern for writing automated tests—prepare, execute logic, verify results—plus naming and packaging guidelines.
Explore test-driven development (TDD) by writing a failing unit test for a calculator's add and average methods, then implement production code and refactor to pass tests.
Master JUnit4 assertions by building a Maven-based testing module and using assertEquals, assertNotEquals, assertTrue, assertFalse, assertNull, assertNotNull, and assertThrows across arrays and primitive types.
Explore the JUnit4 lifecycles by using setup and teardown annotations, including before class, before, and after methods, with examples of ignore tests, expected exceptions, and timeouts.
Learn to implement a JUnit 4 parameterized test that supplies input and expected values via a two-dimensional data table using @RunWith, @Parameters, and a constructor.
Explore how to use JUnit4 test rules to enhance tests, including a temporary folder rule and a custom performance logger rule that prints time spent and validates file creation.
Create a new java module with maven, add junit 5 dependencies, and learn core junit 5 assertions such as assertEquals, assertTrue, assertFalse, assertThrows, and assertArrayEquals through hands-on examples.
Explore the JUnit 5 life cycle annotations, including before all, before each, after each, and after all, plus constructors and static methods, to manage test setup and cleanup.
Learn how to configure repeated tests in JUnit 5 with @RepeatedTest, specify repetitions, and control execution order using @TestMethodOrder and @Order to produce deterministic test runs.
Introduces junit 5 parameterized tests, guiding dependency setup, parameter passing, and value sources such as value source, method source, and csv file source.
Learn how to use JUnit 5 TestInfo to access test class and method details, display names, and tags, and print this information to aid debugging and reporting.
set up a Java module with JUnit 5 and hamcrest, add the core API dependency, and write assertions using hamcrest matchers to compare actual and expected values.
Explore Hamcrest matchers through practical assertions, including is, equal, same instance, array and list checks, map keys and entries, hasProperty, and the anything matcher for flexible testing.
Create a Hamcrest custom matcher by extending a type-safe matcher to check if a string's length exceeds ten, and verify its behavior with a test class.
Learn to create a unit testing module and use Mockito to mock classes and verify interactions. Set expected returns for methods like hello and calculate, with assertions and exception handling.
Learn how to mock an interface using Mockito, set return values with when-then, verify interactions, and handle checked exceptions in unit tests.
Use Mockito argument matchers to stub methods and verify interactions with mocks, employing any string, any int, and custom matchers such as starts with, to handle flexible inputs.
Learn how to use Mockito thenAnswer to implement an answer callback, inspect invocations, access the method name and arguments, and return a value for a mocked say hello test.
As everyone knows, testing is very important for software development. Writing good test code can improve the quality of the software application and make code changes much easier.
- Software testing can also provide an objective, independent view of the software to allow the business to appreciate and understand the risks of software implementation.
- Software testing can provide objective, independent information about the quality of software and risk of its failure to users
This course covers some common software testing techniques and will teach you with code examples. Not only TDD, JUnit, but also Hamcrest Testing, Mockito Testing. I will show you step by step how to write a unit test method and explain the raisons behind.
Keep coding following each section, I believe you will be able to write good testing code throughout your development phase.
Software Testing Basics
- First Unit testing
- Debug Test
- Test coverage
- Test Principles & Good Unit Testing
- Test Driven Development
JUnit4 Testing
- JUnit4 Assertions
- JUnit4 Lifecycles
- JUnit4 Parameterized Test
- JUnit4 Test Rules
JUnit5 Testing
- JUnit5 Assertions
- JUnit5 Lifecycles
- RepeatedTest & Order of Test
- JUnit5 Parameterized Test
- JUnit5 TestInfo
Hamcrest Testing
- Hamcrest Basic
- Hamcrest Matcher Assertions
- Hamcrest Custom Matcher
Mock Testing
- Mockito Mock Class
- Mockito Mock Interface
- Mockito Argument Matchers
- Mockito thenAnswer
If you are interested, join this course and enjoy ~
Finally, you can download the project source code from attachment in the last section.