What Is Integration Testing in Java? JUnit 5 and Testcontainers
Integration tests check that real components work together. Learn how to write them in Java with JUnit 5, Spring Boot Test, Testcontainers and WireMock.
2,889 posts about Java: questions with answers, tutorials and articles, newest first.
Integration tests check that real components work together. Learn how to write them in Java with JUnit 5, Spring Boot Test, Testcontainers and WireMock.
Create and stub mocks with Mockito 5 and JUnit 5 using mock(), @Mock and @InjectMocks, plus spies, argument matchers and good practices.
@Before and @After run before and after each JUnit test to set up and clean up a fixture. JUnit 5 renames them @BeforeEach and @AfterEach.
A JUnit test suite groups test classes, packages or tags into one runnable unit. See the JUnit 5 @Suite setup, selectors, build tool tips and the legacy JUnit 4 way.
A step by step guide to writing JUnit unit tests: dependencies, @Test, assertions, lifecycle methods, parameterized tests and running them.
JUnit is the test framework, Mockito is the mocking library. See how each works and how to combine them with JUnit 5 and the Mockito extension.
Gradle builds faster with incremental tasks and caching and is more flexible than Maven. See a comparison, examples and when Maven still wins.
Define a Gradle custom task with tasks.register, wire dependencies, and write typed task classes with inputs and outputs for caching.
A Gradle configuration groups dependencies by purpose. Learn implementation, api, compileOnly, runtimeOnly, test configurations and how to create your own.
Gradle plugins add tasks, conventions and configuration to your build. See the plugin types, how to apply them and how to write your own.
Compile your classes, package them with the jar tool, set the Main-Class manifest entry and run the result with java -jar, plus Maven and Gradle equivalents.
A Java library is a JAR of reusable classes you call from your code. See examples, Maven and Gradle setup, popular libraries and how to choose one.
Gradle and Maven both build and manage dependencies for JVM projects. See how their build files, speed and flexibility differ and which to pick.
Understand what Apache Maven does for Java projects, from the pom.xml and dependency scopes to lifecycle phases, plugins and multi-module builds.
A Java build tool automates compiling, testing, dependency management and packaging. Learn how Maven and Gradle differ and when to use each.
The sealed keyword restricts which classes can extend or implement a type, giving the compiler a closed set of subtypes for safer design and exhaustive switch.
Java 18 made UTF-8 the default charset and added jwebserver, Javadoc snippets and finalization deprecation. Examples included.
Java 17 ships pattern matching for instanceof, removing explicit casts. Switch patterns were a preview and became final in Java 21 with record patterns.
Use Java switch expressions with arrow cases, yield, and enums. Includes common mistakes and how pattern matching for switch differs in Java 21.
The key Java 17 LTS features with examples, including sealed classes, records and stronger JDK encapsulation, plus what to expect upgrading.