引入依赖

testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.5.2.RELEASE'
testCompile group: 'junit', name: 'junit', version: '4.12'

编写单元测试方法

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringSecurityApplication.class)
public class UserServiceTest {

    @Autowired
    private IUserService userService;
    @Autowired
    private UserRepository userRepository;


    @Test
    public void testService(){
        User user = userService.findById(1L);
        System.out.println(user);
    }

    @Test
    public void testRepository(){
        User user = userRepository.findOne(1L);
        System.out.println(user);
    }

}

就这么简单。

comtrol + alt + O:清理不必要的引入

相关文章:

  • 2021-06-04
  • 2022-02-20
  • 2021-08-28
  • 2021-10-16
  • 2021-07-27
  • 2021-11-09
猜你喜欢
  • 2022-12-23
  • 2021-09-23
  • 2021-11-29
  • 2021-12-28
  • 2022-01-10
  • 2021-10-29
  • 2021-08-21
相关资源
相似解决方案