第一步:
用maven工程导入包`
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
第二步:
写一段java测试代码
package studentInfoManages;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.zhiyuan.frank.mapper.*;
import com.zhiyuan.frank.pojo.s_login;
@RunWith (SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring.xml")
public class TestString {
@Autowired s_loginMapper s_loginMapper;
@Test
public void aaa(){
s_login slo=new s_login();
slo.setSlId(1);
int sl= s_loginMapper .insert(slo);
System.out.println(sl);
}
}
然后运行单元测试
右击项目——》Run As——》JUunit
如果能运行成功有数据就成功了。
报错就可能版本号的问题