Skip to content

Commit 4c939d1

Browse files
committed
完善测试。
1 parent c1ef418 commit 4c939d1

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/test/java/com/github/abel533/test/mysql/TestInsertList.java renamed to src/test/java/com/github/abel533/test/mysql/TestMysql.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.github.abel533.model.Country;
66
import org.apache.ibatis.session.SqlSession;
77
import org.junit.Assert;
8-
import org.junit.Test;
98

109
import java.util.ArrayList;
1110
import java.util.List;
@@ -15,14 +14,14 @@
1514
*
1615
* @author liuzh
1716
*/
18-
public class TestInsertList {
17+
public class TestMysql {
1918

2019
/**
2120
* 插入完整数据
2221
*/
2322
//该方法测试需要mysql或者h2数据库,所以这里注释掉
24-
@Test
25-
public void testInsert() {
23+
//@Test
24+
public void testInsertList() {
2625
SqlSession sqlSession = MybatisHelper.getSqlSession();
2726
try {
2827
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
@@ -43,4 +42,25 @@ public void testInsert() {
4342
sqlSession.close();
4443
}
4544
}
45+
46+
/**
47+
* 插入完整数据
48+
*/
49+
//该方法测试需要mysql或者h2数据库,所以这里注释掉
50+
//@Test
51+
public void testInsert() {
52+
SqlSession sqlSession = MybatisHelper.getSqlSession();
53+
try {
54+
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
55+
Country country = new Country();
56+
country.setCountrycode("CN");
57+
country.setCountryname("天朝");
58+
int count = mapper.InsertUseGeneratedKeysMapper(country);
59+
Assert.assertEquals(1, count);
60+
Assert.assertNotNull(country.getId());
61+
} finally {
62+
sqlSession.rollback();
63+
sqlSession.close();
64+
}
65+
}
4666
}

0 commit comments

Comments
 (0)