← 返回首页
spring-boot-tutorials/testing-spring-boot-basics at main · StackTipsLab/spring-boot-tutorials · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Latest commit

 

History

History
 main
Top

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
View all files

readme.md

Testing Spring Boot REST API using Mockito and MockMvc

The best way to confirm the reliability and correctness of software applications is to write tests that assert the desired behaviour of an application. This post covers how to perform unit and integration testing in Spring Boot.

The spring-boot-starter-teststarter dependency is required for writing the unit and integration tests in the Spring Boot application. The Spring Boot version 3.2.2 spring-boot-starter-test includes the following transitive dependencies.

  • Jupiter JUnit5: The de facto standard for unit testing Java.
  • Jayway JsonPath: A popular Java library used for parsing and querying JSON documents. It is used for navigating through the structure of your JSON data and accessing specific values or elements.
  • Awaitility: Used for waiting for asynchronous operations to complete without introducing additional logic in your code.
  • Hamcrest: Hamcrest is used for writing expressive and readable assertions in unit tests. It provides a clear and concise way to express what you expect from your code, making your tests easier to understand and maintain.
  • Mockito: Java mocking framework used to create mock objects that simulate the behaviour of real objects without actually implementing their functionality. This makes it easier to isolate the code you're testing from external dependencies and write more focused and reliable tests.

Read the full article here

Related topics:

Footer

© 2026 GitHub, Inc.