UserMapperTest.java 910 字节
Newer Older
武汉红喜's avatar
武汉红喜 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
package org.hongxi.whatsmars.spring.boot.dao;

import org.hongxi.whatsmars.spring.boot.model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * Created by shenhongxi on 2018/2/1.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("dev")
public class UserMapperTest {
    @Autowired
    private UserMapper userMapper;

    @Test
    public void insert() {
        assert userMapper != null;
武汉红喜's avatar
武汉红喜 已提交
24
        userMapper.createIfNotExistsTable();
武汉红喜's avatar
武汉红喜 已提交
25 26 27 28 29 30 31 32
        User user = new User();
        user.setUsername("javahongxi");
        user.setNickname("hongxi");
        user.setGender(1);
        user.setAge(28);
        userMapper.insert(user);
    }
}