本人翻译目的是用来学习Tapestry5的,共享出来希望大家批评指正。计划持续翻译。
chinajavawolf
Tapestry 测试效用
这个库现在基于Selenium0.8.1。
策略启动,在过程中,一个Selenimum服务器(轮流,开始和管理一个web浏览器),一个Jetty实例(为与web浏览器对话),和一个Selenium客户端(与服务器对话)。
客户端能够请求URLs,填充表单数据,点击链接,然后制造断言在输出和行为周围。
用法和配置
这个类负责开始一个Jetty实例给你的web应用服务器,也拷贝一个Selenium服务器。它也实现了Selenium接口。
你必须告知套件关于定位你的web应用。这要在你的TestNG配置文件内做:
- <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
- <suite name="My Tapestry Application" parallel="false" thread-count="10" annotations="1.5" verbose="2">
- <test name="Integration Tests">
- <parameter name="tapestry.integration-webapp" value="src/main/webapp"/>
- <packages>
- <package name="org.example.myapp"/>
- </packages>
- </test>
- </suite>
<parameter>元素是一个必须的部分。这将通常是src/main/webapp.
The other part is to create a unit test suite. Here's an example from one of the Tapestry modules:
其他部分是创建一个单元测试套件。这里一个例子来自Tapestry 的一个模块:
- package org.apache.tapestry.spring;
-
- import org.apache.tapestry.test.AbstractIntegrationTestSuite;
- import org.testng.annotations.Test;
-
- public class TapestrySpringIntegrationTest extends AbstractIntegrationTestSuite
- {
- @Test
- public void integration_test() throws Exception
- {
- open(BASE_URL);
-
- type("input", "paris in the springtime");
- clickAndWait("//input[@value='Convert']");
-
- assertFieldValue("input", "PARIS IN THE SPRINGTIME");
- }
- }
这是一个非常简单的例子,并且示范了一个Selenium混合方法(比如open()和type())并且方法通过AbstractIntegrationTestSuite TestSuite 添加给了基类(clickAndWait()和assertFieldValue())。
当然了一个真实的集成测试应该包括很多方法,并且应该需要一个单独的进程执行他们,或者甚至是一个特定的执行顺序。
另外,基类继承了一个普通的异常报告;当一个失败发生在Selenium服务器内时,一个更详细的信息,包括当前页面的HTML源,被报告给System.err。
分享到:
- 2007-05-28 16:06
- 浏览 3138
- 评论(1)
- 论坛回复 / 浏览 (1 / 4658)
- 查看更多
相关推荐
tapestry-bin-5.1.0.5
tapestry-project-4.1.5 裏面有例子和所用到的包
tapestry-4.0.2.jar
apache-tapestry-5.3.8-bin.zip
一个web框架的IOC实现,Apache tapestry-ioc
tapestry-4.0,比较早的版本,也比较稳定,非常使用,适合入门。
tapestry-spring-5.2.6.jar,java spring框架依赖,可以直接使用
apache-tapestry-5.3.7
gaedo-tapestry-0.4.6.jar
gaedo-tapestry-0.4.9.jar
gaedo-tapestry-0.4.4.jar
gaedo-tapestry-0.4.5.jar
gaedo-tapestry-0.4.15.jar
gaedo-tapestry-0.4.3.jar
gaedo-tapestry-0.4.8.jar
Tapestry-3.0的API和组件,详细的使用手册,网页形式查询方便。
Tapestry-3-Getting Started.doc 中文版
chenillekit-tapestry-1.3.2.jar
tapestry-monitoring.zip,Tapestry监视为Tapestry5服务提供性能监视。@通过JMX监视页面/组件和服务接口方法