JUnit 5: Dynamic Tests with TestFactory
How to write dynamic tests using @TestFactory in JUnit 5? This article explains the syntax, different return types, the test lifecycle, and potential use-cases.
09 Apr 2021
Writing Parameterized Tests in JUnit 5
Improving code quality using parameterized tests of JUnit 5! This article explains the motivation, the basic syntax, different annotations, and IDE-related actions about parameterized tests. Also, when you should or shouldn't use it and how to go further from here.
31 Jan 2021
Controlling Time with Java Clock
Use java.time.Clock to control time in your unit tests. This article will mainly focus on usage of fixed clock and offset clock.
24 May 2020
How CompletableFuture is tested in OpenJDK?
How CompletableFuture is tested in OpenJDK 14? What can we learn from it?
10 May 2020
Mockito: 3 Ways to Init Mock in JUnit 5
Initialize Mockito mock objects in JUnit 5 using MockitoExtension, MockitoAnnotations#initMocks, or Mockito#mock.
19 Apr 2020
Testing Elasticsearch With Docker And Java High Level REST Client
Testing Elasticsearch with docker and Java High Level REST Client
05 Apr 2020
Logback: Test Logging Event
Capture SLF4J + Logback logging events and test them in unit tests using ListAppender.
02 Feb 2020
Three ways to create ArgumentCaptor in unit tests (Mockito JUnit Runner, annotations, or factory method) and its different usage.
15 Dec 2019
Mockito: 4 Ways to Verify Interactions
Verify interaction with mock objects with verify(), verifyZeroInteractions() verifyNoMoreInteractions(), and inOrder().
22 Sep 2019
Mockito: 3 Ways to Init Mock in JUnit 4
Initialize Mockito mock objects in JUnit 4 using MockitoJUnitRunner, MockitoAnnotations#initMocks, or Mockito#mock.
13 Sep 2019
6 Tips for Fixing Bugs with Legacy Frameworks
In my daily work, I have to deal with legacy frameworks. Here are 6 tips that I summarized for bug-fixing, including documentation, searching, testing, patching library and more.
13 Aug 2019
TDD: After 3 Months' Practice
I started TDD in all my personal projects 3 months ago. Here're some thoughts about it, including architecture, IDE, methodology, execution speed up, legacy code, and limits.
05 Feb 2019
Testing JAX-RS Resources
This article explains how to set up and tear down a Grizzly Server for testing JAX-RS resources, how to create a HTTP request and assert the response using JUnit 4. And finally, the limits of testing API in reality.
18 Dec 2018
Introduction to Selenium WebDriver
A quick introduction to Selenium WebDriver, a practical tool for running functional tests and browser automation. The sample is written with Firefox 58 and GeckoDriver 0.20.
03 Apr 2018