| Version 1 (modified by chenyang, 14 years ago) (diff) |
|---|
前段时间,公司passport系统升级,jWebUnit 小弑牛刀!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cn.pconline.junit;
import net.sourceforge.jwebunit.junit.WebTester;
import org.junit.Before;
import org.junit.Test;
/**
*
* @author pc
*/
public class ItbbsPassportTest {
private WebTester tester;
@Before
public void setUp() {
tester = new WebTester();
tester.setBaseUrl("http://itbbs.pconline.com.cn");
}
/**
* 测试前台登陆
*/
@Test
public void login() {
tester.beginAt("/index.jsp");
tester.setTextField("username", "chenyaokang");
tester.setTextField("password", "chenyaokang");
tester.submit();
tester.assertTextPresent("欢迎回来");
tester.assertCookiePresent("common_session_id");
tester.assertCookieValueEquals("cmu", "chenyaokang");
}
/**
* 测试前台退出
*/
@Test
public void logout() {
tester.beginAt("/index.jsp");
tester.setTextField("username", "chenyaokang");
tester.setTextField("password", "chenyaokang");
tester.submit();
tester.clickLinkWithText("[退出]", 0);
tester.assertTextNotPresent("chenyaokang");
}
/**
* 测试后台登陆
*/
@Test
public void loginAdmin(){
tester.beginAt("/admin/login.jsp");
tester.setTextField("username", "xxxx");
tester.setTextField("password", "xxxx");
tester.submit();
tester.assertTextPresent("前台帐号登陆");
tester.assertTextPresent("itbbscy");
tester.setTextField("password", "itbbscy");
tester.submit();
tester.assertTextPresent("感谢您使用论坛后台管理系统");
}
}
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/hr/2009/global/images/logo.gif)