package com.jsop;
import org.testng.annotations.Test; import org.testng.annotations.DataProvider; import org.testng.annotations.BeforeClass; import org.testng.Assert; import org.testng.Reporter; import org.testng.annotations.AfterClass;
public class NewTest {
long begin1;
@Test(dataProvider = "dp",invocationCount=50,threadPoolSize=50)
public void logindiscuz(String username, String password) {
Jsoup_get1 my=new Jsoup_get1();
String url="请求地址";
String rawbody="rawbody地址 name="+username+"password="+password;
long begin=System.currentTimeMillis();//记录开始时间
String response=my.postbody(url, rawbody);
long end=System.currentTimeMillis();//记录结束时间
long time=end-begin;
System.out.println("thred="+Thread.currentThread().getId()+" "+time);
Reporter.log(response.toString());//日志
Assert.assertTrue(response.contains("登陆成功")); }
@DataProvider public Object[][] dp() {
return new Object[][] {
new Object[] { "admin", "admin" },
new Object[] { "admin", "pass" }, };
}
@BeforeClass public void beforeClass() {
begin1=System.currentTimeMillis();
}
@AfterClass public void afterClass() {
long end1=System.currentTimeMillis();
long time=end1-begin1;
long tps=100/(time/1000);
System.out.println("总共用时="+time+"tps="+ tps);
Reporter.log("总共用时="+time+"tps="+ tps);
}
}