「webtest」の編集履歴(バックアップ)一覧はこちら
「webtest」(2008/06/07 (土) 14:08:52) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
#contents()
Canoo WebTest 2.0はJavaで作成されたWebアプリケーション用の自動機能試験ツールです。
・公式サイト
http://webtest.canoo.com/webtest/manual/WebTestHome.html
**実行
プロジェクト作成
・プロジェクトフォルダを作成したい場所に移動
※ eclipseで作業したいのでworkspace下にした
cd c:\java\eclipse\workspace\webtest\
・プロジェクト作成
webtest -f c:\java\canoo\webtest.xml wt.createProject
※実行すると、プロジェクト名の入力になるので任意を入れてEnter
実行
・プロジェクトフォルダに移動し、以下を実行
webtest
**設定関連
***myWebTestProject/build.xml
初期設定ファイル
webtestコマンドのデフォルトはこのファイルを参照する。-f xxx.xml等のオプションで別ファイルを指定することも可能
<property name="wt.testInWork" value="tests/allTests.xml"/>
読み込むテストパターンを指定
***myWebTestProject/tests/allTests.xml
通常、build.xmlから呼び出される親テストパターンファイル
ここから各テストパターンファイルを呼び出す形が基本形
<?xml version="1.0"?>
<project name="ESSReplace-allTests" default="test">
<target name="test" description="runs all the tests">
<ant antfile="./Tests.xml"/> ←こんな感じで呼び出すファイルを指定
</target>
</project>
***myWebTestProject/tests/Tests.xml
実際のテストパターンを記述する。
もちろんファイル名は何でも良いし、フォルダ階層作成しても実行可能
<webtest>が一つのテスト単位
<?xml version="1.0"?>
<!DOCTYPE project SYSTEM "../dtd/Project.dtd"> # 階層変更したときはここを変更
<project name="demo.WebTest" default="test">
<target name="test">
<webtest name="check elio : testcode">
<invoke description="Get the page: " url=""/>
<setInputField name="clientip" value=""/>
<clickButton label="testcode_submit"/>
<verifyText text=""/>
</webtest>
<webtest name="check elio : encrypt">
<invoke description="Get the page: " url=""/>
<clickButton label="encrypt_submit"/>
<verifyText text=""/>
</webtest>
<webtest name="check elio : decrypt">
<invoke description="Get the page: " url=""/>
<clickButton label="decrypt_submit"/>
<verifyText text=""/>
</webtest>
<webtest name="check elio : total">
<group description="決済ページを開く">
<invoke description="Get the page: " url=""/>
<clickButton label=""/>
</group>
<group description="入力ページ">
<setSelectField name="" value=""/>
<setInputField name="" value=""/>
<clickButton name=""/>
</group>
<group description="確認ページ">
<verifyText text=""/>
<clickButton name="submit"/>
</group>
<group description="location">
<verifyText text=""/>
<storeRegEx
description="get sid"
text=".*sid=(.*)"><script type="text/javascript">"
group="1"
property="targetLocation" />
<invoke url="act=&t=&sid=#{targetLocation}"/>
</group>
<group description="テスト">
<verifyText text=""/>
<clickButton name="submit"/>
</group>
<group description="">
<verifyText text=""/>
</group>
</webtest>
</target>
</project>
**sqlunit連携
***C:\java\canoo\webtest.xml
1、classpathにsqlunitとdbdriverのjarを追加
<!-- additiona classpath -->
2、sqlunit を taskとして認識させる
<!-- sqlunit tasks -->
<target name="wt.defineTasks.init"
description="Initialisation for wt.defineTasks">
<!-- Define the classpath -->
<path id="wt.defineTasks.classpath.webtest">
<pathelement location="${~wt.WebTest.dir}/lib"/>
<!-- to find webtest's log4j properties -->
<fileset dir="${~wt.WebTest.dir}/lib" includes="*.jar"/>
</path>
<!-- Placeholders for customisation, here empty (customisation has to occur after this definition as path can be overriden)-->
<path id="wt.defineTasks.classpath.customPrepend"/>
<path id="wt.defineTasks.classpath.customAppend"/>
<!-- additiona classpath -->
<path id="wt.defineTasks.classpath.database">
<pathelement location="C:\java\mysql-connector-java-5.0.8\mysql-connector-java-5.0.8-bin.jar"/>
</path>
<path id="wt.defineTasks.classpath.sqlunit">
<pathelement location="C:\java\sqlunit-5.0\lib\"/>
<fileset dir="C:\java\sqlunit-5.0\lib\" includes="*.jar"/>
</path>
</target>
<target name="wt.defineTasks" depends="wt.init, wt.defineTasks.init" unless="wt.defineTasks.skip"
description="defines the WebTest tasks as well as groovyScript">
<!-- Define the classpath -->
<path id="wt.defineTasks.classpath.id">
<path refid="wt.defineTasks.classpath.customPrepend"/>
<path refid="wt.defineTasks.classpath.webtest"/>
<path refid="wt.defineTasks.classpath.sqlunit"/>
<path refid="wt.defineTasks.classpath.database"/>
<path refid="wt.defineTasks.classpath.customAppend"/>
</path>
<!-- Webtest tasks -->
<taskdef resource="webtest.taskdef"
loaderref="wt.defineTasks.loader"
classpathref="wt.defineTasks.classpath.id"
/>
<!-- the standard Ant Groovy task -->
<taskdef name="groovyScript" classname="org.codehaus.groovy.ant.Groovy"
loaderref="wt.defineTasks.loader"
classpathref="wt.defineTasks.classpath.id"/>
<!-- sqlunit tasks -->
<taskdef name="sqlunit" classname="net.sourceforge.sqlunit.ant.SqlunitTask"
loaderref="wt.defineTasks.loader"
classpathref="wt.defineTasks.classpath.id"/>
<property name="wt.defineTasks.skip" value="true" description="Avoid this target to be called twice in a run"/>
</target>
#contents()
Canoo WebTest 2.0はJavaで作成されたWebアプリケーション用の自動機能試験ツールです。
・公式サイト
http://webtest.canoo.com/webtest/manual/WebTestHome.html