用中文方法名测试

是不是也有趣
package com.i7i8i9.base2.service.impl;

import com.i7i8i9.base2.Base2Application;
import com.i7i8i9.base2.Request.LoginReq;
import com.i7i8i9.base2.exception.BusinessException;
import com.i7i8i9.base2.model.SysUser;
import com.i7i8i9.base2.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import static org.junit.jupiter.api.Assertions.*;


@SpringBootTest(classes = Base2Application.class)
@Slf4j
class LoginServiceImplTest {
      @Autowired
    LoginService loginService;
    @Test
    void 用户不存在测试() {
        try{LoginReq loginReq=new LoginReq();
        loginReq.setUsername("dff");
        loginReq.setPassword("123456");
        loginService.Login(loginReq);}catch (BusinessException e){
            log.error("用户名不存在{}",e.getMessage());

        }
    }
    @Test
    void 密码错误() {
        try{LoginReq loginReq=new LoginReq();
            loginReq.setUsername("admin");
            loginReq.setPassword("123456778");
            loginService.Login(loginReq);}catch (BusinessException e){
            log.error("密码错误{}",e.getMessage());

        }
    }
    @Test
    void 正确() {
             LoginReq loginReq=new LoginReq();
            loginReq.setUsername("admin");
            loginReq.setPassword("123456");
           String loginToken= loginService.Login(loginReq);
           log.info("登陆成功,{}",loginToken);
    }
}

你可能感兴趣的:(数据库)