testng學習日記-10/21

package com.gubo;

import org.testng.annotations.*;

import com.meterware.httpunit.*;

public class HttpUnitTest {

@Test

public static void main(String[] args) {

try {

WebConversation wc = new WebConversation();

WebRequest request =new GetMethodWebRequest("http://www.google.cn");   //打開網頁

//wc.setProxyServer( "your.proxy.com", 80 );

WebResponse response = wc.getResponse(request);

WebLink httpunitLink =

response.getFirstMatchingLink(WebLink.

MATCH_CONTAINED_TEXT,"圖片");                                                    //點擊按鈕

response = httpunitLink.click();

System.out.println("Test successful !!");

} catch (Exception e) {

System.err.println("Exception: " + e);

}

}

@Configuration(beforeTestClass = true)

public void doBeforeTests() {

System.out.println("invoke before test class!");

}

@Configuration(afterTestClass = true)

public void doAfterTests() {

System.out.println("invoke after test class!");

}

}

 

 

安裝了jwunit後,寫的一小段測試代碼

能跑通,但是testng依然報未通過,明天弄吧

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章