springboot 單元測試

package cn.enjoy.test;java

 

import cn.enjoy.App;spring

import cn.enjoy.dao.UsersMapper;app

import cn.enjoy.model.Users;.net

import org.junit.Test;get

import org.junit.runner.RunWith;it

import org.springframework.boot.test.context.SpringBootTest;io

import org.springframework.test.context.junit4.SpringRunner;class

import javax.annotation.Resource;test

 

@SpringBootTest(classes = {App.class})import

@RunWith(SpringRunner.class)

public class UserTest {

    @Resource

    private UsersMapper usersMapper;

 

    @Test

    public void testAdd() {

        Users user = new Users() ;

        user.setPasswd("123");

        user.setUsername("enjoy");

        usersMapper.insertSelective(user);

    }

    @Test

    public void testFindUser() {

        Users enjoy = usersMapper.findByUsernameAndPasswd("enjoy", "123");

        System.out.println(enjoy);

    }

}

相關文章
相關標籤/搜索