Web testing BDD-style with JWebUnit and Easyb

本文探讨了如何结合JWebUnit和Easyb这两种强大的框架,实现行为驱动开发(BDD),用于构建应用的Web层。通过一个简单的示例,展示了如何创建易于使用的测试用例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Behaviour-driven development is a great way to design and build the web layers of your application. In this article, I look at how to use JWebUnit, a fast and light-weight web testing framework, with Easyb, a powerful Groovy-based BDD framework.

JWebUnit is a web testing framework built on HTMLUnit. It runs in memory, so it's fast. However, it also has an intuitive, high-level API, making it easy to use even if you have only an approximate idea of the exact HTML details of your application screens. A simple JWebUnit test case is shown here:

import net.sourceforge.jwebunit.junit.WebTestCase;
import net.sourceforge.jwebunit.junit.WebTester;

public class TestJWebUnitDepositStoryUI extends WebTestCase {

public void setUp() {
setBaseUrl("http://localhost:9090/ebank-web");
}

public void testDepositingCashShouldAddToBalance() {
beginAt("/");
assertTextPresent("Current Balance: $0");
setTextField("depositAmount","100");
clickButtonWithText("deposit");
assertTextPresent("Current Balance: $100");
}
}


详细链接如下:http://www.wakaleo.com/component/content/article/183
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值