testng + junit

上一篇 / 下一篇  2009-04-01 18:03:03 / 个人分类:Selenium

一个例子,最少更改junit testcase 的方式,用testng来跑。
跑多个环境。。
51Testing软件测试网Che2@ ~%|;p.TQRi
package test;
51Testing软件测试网4ZAxN'~XBEN4c
51Testing软件测试网3{ g$FH U{0o
import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
51Testing软件测试网)x/tV/MN,Q0b&k8c;o
import junit.framework.TestCase;
51Testing软件测试网3qH Q mKTe9~l
import org.testng.annotations.*;
51Testing软件测试网xv+v,R7N6uK^
public class NewTest extends TestCase{
@Test()
public void testNew() throws Exception {
Selenium selenium = new DefaultSelenium("localhost",4444,"*chrome","http://www.google.cn");
script(selenium);
}
@Test()
public void testNew2() throws Exception {
Selenium selenium = new DefaultSelenium("localhost",4444,"*iehta","http://www.google.cn");
script(selenium);
}
private void script(Selenium selenium)throws Exception{
try{
selenium.start();
selenium.open("http://www.google.cn/");
selenium.type("q", "selenium");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
assertEquals("selenium - Google 搜索", selenium.getTitle());
}catch(Exception e){
throw e;
}finally{
selenium.stop();
}
}
}

{6Nqj3uo6L;Su0
51Testing软件测试网q5ip(bP0u td b

TAG:

看雪时节的个人空间 引用 删除 看雪时节   /   2009-04-01 18:11:22
谢谢Bruce在群里给我的讲解,还写了这个代码!~~
 

评分:0

我来说两句

Open Toolbar