1. Generate unit test files
1) Click the mouse on the class you want to unit test and use Alt+Enter
2) Select Create Test
package com.example.demo.service.impl; import com.example.demo.model.TestModel; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import java.util.List; @Slf4j@SpringBootTestclass TestServiceImplTest { @Autowired private TestServiceImpl testService; @BeforeEach void setUp() { log.info("setUp"); } @AfterEach void tearDown() { log.info("tearDown"); } @Test void testMethod() { List<TestModel> a = testService.testMethod(); for (TestModel b:a ) { log.info("{}",b); }}}Copy the code
3) Select the method you want to test
4) Override the generated method
5) Click Method Make to run the unit test method
Second, the packaging
Pack two options:
The first is to double-click the package and directly open the JAR package. After the package, the file is in the project directory /target/
The second is to double-click install, which will delete the original target directory files before packaging