In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people don't understand the knowledge points of this article "How to use JUnit to implement unit testing in SpringBoot", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "How to use JUnit to implement unit testing in SpringBoot".
1. You need to introduce spring-boot-starter-test in pom.xml
org.springframework.boot spring-boot-starter-test
2. unit test code
Two key notes
@RunWith(SpringRunner.class)
@SpringBootTest
package com.niugang.test;import java.util.List;import javax.annotation.Resource;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.test.context.junit4.SpringRunner;import com.niugang.entity.User;import com.niugang.service.UserService;
@RunWith(SpringRunner.class)
@SpringBootTestpublic class TestUser {
@Resource private UserService userService;
@Testpublic void test1(){List list = userService.queryList(null);System.out.println("Collection size: "+list.size());}}
Springboot is a brand new programming specification designed to simplify the initial build and development process of new Spring applications. SpringBoot is also a framework that serves the framework. The scope of services is to simplify configuration files.
The above is about the content of this article on "How to use JUnit to implement unit testing in SpringBoot". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more related knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.