此文档是毕业设计外文翻译成品( 含英文原文+中文翻译),无需调整复杂的格式!下载之后直接可用,方便快捷!本文价格不贵,也就几十块钱!一辈子也就一次的事!
文献出处:K. Siva Prasad Reddy Beginning Spring Boot 2,2019: pp 221-246(如觉得年份太老,可改为近2年,毕竟很多毕业生都这样做)
英文3129单词,19338字符(字符就是印刷符),中文4965汉字。(如果字数多了,可自行删减,大多数学校都是要求选取外文的一部分内容进行翻译的。)
Testing Spring Boot Applications
Testing is an important part of software development. It helps developers verify the correctness of the functionality. JUnit and TestNG are two of the most popular testing libraries used in Java projects. Test Driven Development (TDD) is a popular development practice where you write tests first and write just enough production code to pass the tests. You write various types of tests, such as unit tests, integration tests, performance tests, etc. Unit tests focus on testing one component in isolation, whereas integration tests verify the behavior of a feature, which could possibly involve multiple components. While doing integration testing, you may have to mock the behavior of dependent components such as third-party web service classes, database method invocations, etc. There are mocking libraries like Mockito, PowerMock, and jMock, for mocking the object’s behavior.
The dependency injection (DI) design pattern encourages programming to practice and write testable code. With dependency injection, you can inject mock implementations for testing and real implementations for production. At its core, Spring is a dependency injection container and it provides great support for testing various parts of an application.
In this chapter, you will learn how to test Spring components in Spring Boot applications. You will take a detailed look at how to test slices of applications, such as web components (regular MVC Controllers, REST API endpoints), Spring data repositories, and secured controller/ service methods using the @WebMvcTest , @Dat aJpaTest , and the @JdbcTest annotations.
Testing Spring Boot Applications
One of the key reasons for the popularity of the Spring framework is its great sup