<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # 10B 高級 WebDriver – 生成 JUnit 報告 > 原文: [https://javabeginnerstutorial.com/selenium/10b-advanced-webdriver-generating-junit-reports/](https://javabeginnerstutorial.com/selenium/10b-advanced-webdriver-generating-junit-reports/) 嗨冠軍! 報告,報告,無處不在的報告。 從哈利·波特時代開始,我們就一直在處理這些問題!! (還記得學校的進度報告嗎?!)無論如何,報告真的很重要,尤其是在測試中,以便快速了解一切工作原理。 因此,今天,我們將使用 Apache ANT 的`junitreport`任務來生成一個任務。 熱身! 從我的[上一篇文章](https://javabeginnerstutorial.com/selenium/10a-advanced-webdriver-apache-ant/)中,我們生成了帶有“`junit`”作為默認 JUnit 輸出目錄的構建文件。 用簡單的英語來說,這僅意味著將作為 JUnit 報告任務的一部分生成的所有文件都放置在名為“`junit`”的目錄下。 #### 步驟 1 : 在項目“Selenium”下,將生成名為“`build.xml`”的 ANT 構建文件。 我已經在“`com.blog.junitTests`”包下創建了兩個 JUnit 測試用例,分別是 [RadioBtns_Checkboxes.java](https://javabeginnerstutorial.com/selenium/9t-webdriver-handling-radio-buttons-checkboxes/) 和 [SelectItems.java](https://javabeginnerstutorial.com/selenium/9u-webdriver-select-items-two-ways/) ,如下圖所示。 該代碼可在相應的帖子中找到。 只需單擊文件名即可進行導航。 ![Package structure](https://img.kancloud.cn/c6/13/c61374ca0637aefe744c9a1f74a44af2_354x273.png) #### 步驟 2 : 打開“`build.xml`”,并確保自動生成“`junitreport`”任務。 以下是我的項目的目標(初始化,清理,構建,`RadioBtns_Checkboxes`,`SelectItems`和`junitreport`)。 ```xml <project basedir="." default="build" name="Selenium"> <property environment="env"/> <property name="junit.output.dir" value="junit"/> <property name="debuglevel" value="source,lines,vars"/> <property name="target" value="1.8"/> <property name="source" value="1.8"/> <target name="init"> <mkdir dir="bin"/> <copy includeemptydirs="false" todir="bin"> <fileset dir="src"> <exclude name="**/*.java"/> </fileset> </copy> </target> <target name="clean"> <delete dir="bin"/> </target> <target name="build" depends="init"> <echo message="${ant.project.name}: ${ant.file}"/> <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}"> <src path="src"/> <classpath refid="Selenium.classpath"/> </javac> </target> <target name="RadioBtns_Checkboxes"> <mkdir dir="${junit.output.dir}"/> <junit fork="yes" printsummary="withOutAndErr"> <formatter type="xml"/> <test name="com.blog.junitTests.RadioBtns_Checkboxes" todir="${junit.output.dir}"/> <classpath refid="Selenium.classpath"/> </junit> </target> <target name="SelectItems"> <mkdir dir="${junit.output.dir}"/> <junit fork="yes" printsummary="withOutAndErr"> <formatter type="xml"/> <test name="com.blog.junitTests.SelectItems" todir="${junit.output.dir}"/> <classpath refid="Selenium.classpath"/> </junit> </target> <target name="junitreport"> <junitreport todir="${junit.output.dir}"> <fileset dir="${junit.output.dir}"> <include name="TEST-*.xml"/> </fileset> <report format="frames" todir="${junit.output.dir}"/> </junitreport> </target> </project> ``` #### 步驟 3 : 可以通過以下任意一種方式執行構建, 1.右鍵單擊“構建文件(`build.xml`)-> 運行方式 -> Ant Build” ![Report Generation Method 1](https://img.kancloud.cn/e6/46/e6469cc85b5e34b69785328239203d36_775x416.png) 2.右鍵單擊“構建文件(`build.xml`)-> 運行方式 -> 外部工具配置 -> 運行” 3.蝕工具欄中的快捷方式運行圖標 ![Report Generation Method 2](https://img.kancloud.cn/0f/80/0f80bba9578184bf149d5d87b4e62ee7_536x201.png) 讓我們采用第二種方法,看看如何使用“外部工具配置”選項修改現有配置。 因此,右鍵單擊“構建文件->運行方式->外部工具配置”:這將打開一個彈出窗口。 選擇“主要”標簽,并確保選擇了正確的構建文件。 ![Main Configuration](https://img.kancloud.cn/84/e7/84e75fd47d4d4984fcd2d1d101ce90a7_783x248.png) 然后點擊“目標”標簽。 1. 將列出構建文件中定義的所有目標名稱,并且僅檢查默認目標。 點擊“運行”,選擇要執行的所有目標。 2. 在“目標執行順序”框中,將從上一步中選擇的所有目標按執行順序列出。 3. 如果您想更改順序,請點擊“順序...”。 這將打開“順序目標”彈出窗口。 4. 我們可以通過選擇目標并相應地單擊“上”或“下”按鈕來在此彈出窗口中指定目標執行順序。 點擊“確定”以確認最終的執行順序。 5. 完成所有操作后,點擊“應用”和“運行” ![ANT target configuration](https://img.kancloud.cn/98/8e/988ef695da143fd5cc8bc2bc4b37028c_845x591.png) #### 步驟 4 : 可以通過查看控制臺視圖來驗證成功執行。 它顯示了按配置順序執行的所有目標以及基于構建文件中提到的日志記錄級別的日志。 如圖所示,將顯示運行構建所花費的總時間以及消息“`BUILD SUCCESSFUL`”或“`BUILD FAILED`”。 ![Console Output](https://img.kancloud.cn/fc/61/fc615be833cfdf70402d70bc4397f510_790x515.png) #### 步驟 5 : 在 Eclipse 的“包瀏覽器”視圖中,右鍵單擊該項目,然后單擊“刷新”或`F5`。 已經創建了“`junit`”文件夾(在生成構建文件時在“JUnit 輸出目錄”框中指定的名稱)。 這是 JUnit 報告(`index.html`)和 XML 一起提供的地方,用于執行的每個測試用例,顯示其成功或失敗。 ![Report in JUnit folder](https://img.kancloud.cn/8f/f2/8ff28ef7d5a46a5d2428bd8b1e3261a1_646x402.png) 或者,在文件瀏覽器中導航到項目路徑,然后雙擊“`junit`”文件夾。 #### 步驟 6 : 在瀏覽器中打開“`index.html`”,并檢查生成的默認報告。 這將在左窗格中顯示所涉及的包和所有已執行的 Java 文件。 右窗格顯示測試結果的摘要,其中包括測試的總數,失敗,錯誤,跳過,成功率和執行時間。 還顯示了包列表,其中包含類似的詳細信息。 要深入查看所有已執行的測試或失敗等,請單擊顯示的數字,如下圖所示, ![Generated report](https://img.kancloud.cn/d0/5b/d05be2c3211bd1560654e9a69dd50dab_761x436.png) 用 Apache ANT 生成 JUnit 報告不是一件容易的事嗎? 猜猜這就是我們今天要做的。 在另一篇文章中再見。 祝您報告愉快!
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看