Springboot統合junit

3422 ワード

導入依存
 
<dependency> 
    <groupId>org.springframework.bootgroupId>  
    <artifactId>spring-boot-starter-testartifactId>
    <scope>testscope>
dependency>

テスト

@RunWith(SpringRunner.class) 
@SpringBootTest(classes = MySpringBootApplication.class)  // 
public class MapperTest {
    @Autowired   
    private UserMapper userMapper;

    @Test    public void test() { 
        List<User> users = userMapper.queryUserList();     
        System.out.println(users);   
    }

}