您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源功能測(cè)試工具 > Selenium
Selenium自動(dòng)化測(cè)試框架的搭建
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2014/1/7 16:53:42 ] 推薦標(biāo)簽:自動(dòng)化測(cè)試 Selenium 測(cè)試工程

四、Coverlipse的安裝

1.        直接通過(guò)Eclipse即可安裝,步驟如下

    In Eclipse, click Help -> Software Updates -> Find and Install.
    In the dialog, select Search for new features to install, then Next.
    In the next step, add a New Remote Site. Name it "Coverlipse update site", the URL is "http://coverlipse.sf.net/update/".
    Press Finish. Eclipse now searches for the Coverlipse feature to install and shows that to you.

2.        配置Coverlipse以獲取代碼覆蓋

 

3.        一旦單擊了Run,Eclipse會(huì)運(yùn)行Coverlipse并在源代碼(如圖7所示)中嵌入標(biāo)記,該標(biāo)記顯示了具有相關(guān)JUnit測(cè)試的代碼部分

4.    Coverlipse生成的具有嵌入類標(biāo)記的報(bào)告

5.     正如您所見,使用Coverlipse Eclipse插件可以更快地確定代碼覆蓋率。例如,這種實(shí)時(shí)數(shù)據(jù)功能有助于在將代碼簽入CM系統(tǒng)前更好地進(jìn)行測(cè)試。

五、ANT安裝,eclipse自帶,只需要配置環(huán)境變量ant_home即可。


六、創(chuàng)建一個(gè)案例

1.        創(chuàng)建一個(gè)工程testSelenium安裝下面目錄結(jié)構(gòu)

2.        錄制腳本,打開Firefox瀏覽器,進(jìn)入selenium IDE菜單

3.        輸入相應(yīng)錄制的地址,點(diǎn)擊紅色按鈕,開始錄制

4.        將腳本轉(zhuǎn)換成junit代碼,然后將其拷貝到測(cè)試類中做為測(cè)試CASE編碼的雛形。

六、如何查看日志,這里日志分兩類:

l         Junit日志,通過(guò)junit寫的斷言,和標(biāo)準(zhǔn)輸出,這些操作產(chǎn)生的日志記錄。

l         Selenium日志,當(dāng)運(yùn)行junit腳本時(shí),selenium相關(guān)的腳本會(huì)產(chǎn)生回放日志,例如打開界面的url,標(biāo)準(zhǔn)輸入,輸出等信息。

   雖然這兩種日志沒(méi)有交集,需要分開查看。但一般情況下我們只需要觀察Selenium日志已經(jīng)足夠用了,與其相比Junit日志更適用于編碼階段。

1.      Junit日志,只需要配置腳本build-selenium.xml,如下

<project name="seleniumTest"default="junit" basedir=".">

      <propertyenvironment="env" />

      <conditionproperty="ia.home" value="${env.IA_HOME}">

             <issetproperty="env.IA_HOME" />

      </condition>

      <propertyname="run.classpath" value="../class">

      </property>

      <propertyname="run.srcpath" value="../testSelenium">

      </property>

      <propertyname="test.xml" value="../xml">

      </property>

      <propertyname="test.report" value="../report">

      </property>

      <propertyname="lib.dir" value="../lib" />

      <pathid="compile.path">

             <filesetdir="${lib.dir}">

                    <includename="junit.jar" />

                    <includename="ant.jar" />

             </fileset>

      </path>

      <targetname="init">

             <deletedir="${run.classpath}" />

             <mkdirdir="${run.classpath}" />

             <deletedir="${test.report}" />

             <mkdirdir="${test.report}" />

             <deletedir="${test.xml}" />

             <mkdirdir="${test.xml}" />

      </target>

      <targetname="compile" depends="init">

             <javacdestdir="${run.classpath}" srcdir="${run.srcpath}" />

      </target>

      <targetname="junit" depends="compile">

             <junitprintsummary="false">

                    <classpathpath="${run.classpath}">

                           <pathrefid="compile.path" />

                    </classpath>

                    <formattertype="xml" />

                    <batchtesttodir="${test.xml}">

                           <filesetdir="${run.classpath}">

                                  <includename="**/Test*.class" />

                                  <includename="**/*Test.class" />

                           </fileset>

                    </batchtest>

             </junit>

             <junitreporttodir="${test.xml}">

                    <filesetdir="${test.xml}">

                           <includename="TEST-*.xml" />

                    </fileset>

                    <reportformat="frames" todir="${test.report}" />

             </junitreport>

      </target>

</project>

上一頁(yè)12345下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd