<dependency>
<groupId> junitgroupId >
<artifactId> junitartifactId >
<version> 4.10version >
<scope> testscope >
dependency>
<dependency>
<groupId> org.springframeworkgroupId >
<artifactId> spring-testartifactId >
<version> 3.2.6.RELEASEversion >
dependency>
<dependency>
<groupId> org.springframeworkgroupId >
<artifactId> spring-contextartifactId >
<version> 3.2.6.RELEASEversion >
dependency>
@RunWith(SpringJUnit4ClassRunner. class) //使用junit4进行测试
@ContextConfiguration
({
"file:src/main/webapp/WEB-INF/applicationContext-datasource.xml",
"file:src/main/webapp/WEB-INF/spring/*.xml"
...
}) //加载配置文件
public class BaseJunit4Test {
@Test
public void testInsertUserAssign() { }
}
public class UserinfoTest extends BaseJunit4Test{
@Resource //自动注入,默认按名称
private UserInfoManager userInfoManager;
@Test //标明是测试方法
//@Transactional //标明此方法需使用事务
//@Rollback(false) //标明使用完此方法后事务不回滚,true时为回滚
public void testInsertUserAssign() {
for(int i=0;i<10;i++){
Long a = System. currentTimeMillis();
userInfoManager.getByUUID("85ced0e9-3e54-11e4-b372-005056b76f10" );
System. out.println("userInfo执行耗时 : "+(System.currentTimeMillis ()-a)/1000f+" 秒 " );
}
}
}
阅读(2093) | 评论(0) | 转发(0) |