<< 我收藏的链接(17) | 首页 | Spring+Hibernate大批量处理数据 >>

用Webtest来做web功能测试

webtest版本:R_1649

ant安装:

ANT_HOME=D:\Downloads\apache-ant-1.7.0

PATH=%PATH%;D:\Downloads\apache-ant-1.7.0\bin;

build.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project name="psmis" basedir="." default="package-web">

    <!-- import properties (app settings, classpath, jar file locations) -->
    <import file="properties.xml"/>

    <!-- =================================================================== -->
    <!--            Run Canoo WebTests in Tomcat                             -->
    <!-- =================================================================== -->
    <target name="test-canoo" if="tomcat.home" depends="ping-tomcat,db-load"
        description="Runs Canoo WebTests in Tomcat to test JSPs">

        <taskdef file="${webtest.dir}/webtestTaskdefs.properties">
            <classpath>
                <path refid="web.test.classpath"/>
                <!-- for log4j.properties -->
                <path location="${build.dir}/web/classes"/>
            </classpath>
        </taskdef>

        <mkdir dir="${test.dir}/data"/>
       
        <!-- Delete old results file if it exists -->
        <delete file="${test.dir}/data/web-tests-result.xml"/>
       
        <!-- This is so the default will be used if no test case is specified -->
        <property name="testcase" value="run-all-tests"/>
        <echo level="info">Testing with locale '${user.language}'</echo>
        <ant antfile="test/web/web-tests.xml" target="${testcase}"/>
    </target>

webtest:

webtestTaskdefs.properties
webtest.xml

webtest/lib/:

webtest.jar
commons-httpclient-3.1.jar
commons-io-1.3.1.jar
htmlunit-1.14.jar
jaxen-1.1.1.jar
js-1.6R7.jar
log4j-1.2.14.jar
nekohtml-0.9.5.jar
poi-3.0.1-FINAL.jar
cssparser-0.9.4.jar

 

web-tests.xml:

<!-- ======================================================================= -->
<!-- $Id: web-tests.xml,v 1.19 2006/01/13 07:21:08 mraible Exp $               -->
<!-- ======================================================================= -->
<!DOCTYPE project [
    <!ENTITY config SYSTEM "file:./config.xml">
    <!ENTITY login SYSTEM "file:./login.xml">
]>
<project basedir="." default="run-all-tests">
    <!-- Use i18n bundle, 2nd one listed is the default -->
    <property file="${build.dir}/web/classes/ApplicationResources_${user.language}.properties"/>
    <property file="web/WEB-INF/classes/ApplicationResources.properties"/>

  <import file="../../lib/webtest-build1263/webtest.xml"/>

    <!-- runs all targets -->
    <target name="run-all-tests"
        depends="Login,Logout,PasswordHint,Signup,UserTests,FlushCache,FileUpload"
        description="Call and executes all test cases (targets)"/>
   
    <!-- runs user-related tests -->
    <target name="UserTests"
        depends="EditUser,SearchUser,SaveUser,AddUser,ActiveUsers"
        description="Call and executes all user test cases (targets)">
        <echo>Successfully ran all User JSP tests!</echo>
    </target>

 

标签 : ,



发表评论 发送引用通报