SpringBoot Test Junit 联用

  • 需要导入SpringBoot test和junit的包
@RunWith(SpringRunner.class)
@SpringBootTest(classes = PiYuApplication.class)
public class UserServiceTest {

    @Autowired
    UserService userService;

    /**
     * 测试注册
     */
    @Test
    public void testRegister(){
        User user = new User();
        user.setUsername("小皮");
        user.setPassword("123456");
        user.setEmail("22920@qq.com");
        System.out.println(userService.registerUser(user));
    }

posted @ 2021-01-16 15:05  皮豪  阅读(86)  评论(0编辑  收藏  举报