<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 如何在 Eclipse 中下載和安裝 JUnit > 原文: [https://www.guru99.com/download-installation-junit.html](https://www.guru99.com/download-installation-junit.html) 安裝 Junit 是一個 6 部分的過程。 下面詳細解釋- ## 第 1 部分)安裝 Java JUnit 是一個[測試](/software-testing.html)框架,用于測試基于 Java 的應用程序。 因此,在安裝 JUnit 之前,您需要在計算機中配置或驗證 Java 開發工具包(JDK)。 單擊此[教程](/install-java.html)下載并安裝 Java ## 第 2 部分)下載 JUnit **步驟 1)**訪問 [http://junit.org/junit4/](http://junit.org/junit4/) ,然后點擊下載并安裝 ![How to Download and Installation JUnit](https://img.kancloud.cn/cc/01/cc01a9a2370a425193980f83b61c072e_699x399.png "How to Download and Installation JUnit") **步驟 2)**單擊 junit.jar ![How to Download and Installation JUnit](https://img.kancloud.cn/80/4c/804c81e2dfc21536156c80edb11fe050_506x446.png "How to Download and Installation JUnit") **步驟 3)**在中央存儲庫中,顯示了可以下載的所有 Junit 版本。 通常,您將選擇最新版本。 單擊 jar 鏈接以下載 Junit 版本 4.12,如下所示 ![How to Download and Installation JUnit](https://img.kancloud.cn/44/b7/44b7f6f41e856a78a9445b6b85d9a012_1009x413.png "How to Download and Installation JUnit") **步驟 4)**再次訪問 [https://github.com/junit-team/junit4/wiki/下載并安裝](https://github.com/junit-team/junit4/wiki/Download-and-Install)。 點擊 hamcrest-core.jar ![How to Download and Installation JUnit](https://img.kancloud.cn/a8/0e/a80e7328f56c2232e3fc4e32c62dd8c4_512x192.png "How to Download and Installation JUnit") **步驟 5)**下載 Jar [![How to Download and Installation JUnit](https://img.kancloud.cn/f1/9c/f19c05567bc4479a7b18e62adf5d2870_838x132.png "How to Download and Installation JUnit") ](/images/junit/051716_0555_HowtoDownlo5.png) 對于 JUnit 安裝,您需要 JUnit jar,并且可以從 JUnit 官方網站 [http://www.junit.org](https://junit.org/junit5/) 下載所需的 JUnit jar 文件版本。 這是罐子列表: * JUnit.jar * hamcrest-core.jar ## 第 3 部分)JUnit 環境設置 **步驟 1)**您需要設置 **JUNIT_HOME** 環境變量,以指出放置 JUnit Jar 的基本位置。 例如,如果您已經在 c:驅動器中創建了一個 JUnit 文件夾并將 jar 放在其中,那么對于環境設置,您需要打開控制面板->高級->環境變量。 1. 在環境窗口下,單擊“新建”按鈕。 ![How to Download and Installation JUnit](https://img.kancloud.cn/65/f4/65f4b45aa691abf4671e92e28ac6f631_394x436.png "How to Download and Installation JUnit") 當您在環境變量中單擊新按鈕時,它將打開另一個窗口 **步驟 2)**將打開“新系統變量”窗口: 1. 提供變量名稱為“ JUNIT_HOME”。 2. 提供 JUnit 值作為已復制 JUnit jar 文件的 JUnit 路徑。 3. 單擊確定。 ![How to Download and Installation JUnit](https://img.kancloud.cn/05/af/05af07d79c1db81b583fe59d8b3bd6cc_364x156.png "How to Download and Installation JUnit") 當您單擊確定時,它將使用給定的名稱和值創建一個新的系統變量。 您可以在環境變量窗口中進行驗證,如步驟 1 所示。 **步驟 3)**創建 JUNIT_HOME 之后,創建另一個名為 CLASSPATH 的變量。 再次轉到環境變量,然后執行以下步驟。 1. Click on "new" button. When you click on new in environment variables, it will open another window. ![How to Download and Installation JUnit](https://img.kancloud.cn/39/ed/39ed0b617c9b4a9cdf2d7040801c7bf3_395x437.png "How to Download and Installation JUnit") **步驟 4)**在此步驟中,將 JUNIT_HOME 指向放置在 JUnit 文件夾中的 [JUnit.jar](https://bit.ly/My9IXz) ,如下所示: 1. 變量名稱:CLASSPATH 2. 變量值:%CLASSPATH%;%JUNIT_HOME%\ JUnit4.10.jar;。; 3. 單擊確定按鈕。 ![How to Download and Installation JUnit](https://img.kancloud.cn/be/2b/be2bf814d97c016d764ccef188236d47_357x153.png "How to Download and Installation JUnit") **步驟 5)**單擊“確定”按鈕后,可以驗證是否可以在系統變量下看到名為“ CLASSPATH”的新環境變量。 見下文 ![How to Download and Installation JUnit](https://img.kancloud.cn/d3/79/d379148f7465cd0b916872a1557a3730_394x436.png "How to Download and Installation JUnit") ## 第 4 部分)在 Eclipse 中安裝 JUnit jar 文件 **步驟 1)**右鍵點擊項目: 1. 點擊“構建路徑”,然后點擊 2. 單擊“配置構建路徑”。 ![How to Download and Installation JUnit](https://img.kancloud.cn/01/33/013376aa00d9500310c4bc99ebbdd388_523x165.png "How to Download and Installation JUnit") **步驟 2)**在此步驟中, 1. 轉到 Java 構建路徑窗口,如下圖所示 2. 現在,單擊“添加外部 JAR”按鈕以使用 Eclipse 添加下載的 JUnit.jar 文件。 添加 JUnit.jar 文件后,單擊“確定”按鈕以關閉 Java 構建路徑窗口。 ![How to Download and Installation JUnit](https://img.kancloud.cn/9e/39/9e39c6d82b3a959cd7bdc7b634a7f85e_712x240.png "How to Download and Installation JUnit") ## 第 5 部分)驗證 JUnit 所需的 jar 文件是否在我的構建路徑中 為了在 Eclipse 中驗證 JUnit jar 文件,您需要執行以下步驟: 1. 右鍵單擊項目->構建路徑 2. 單擊“配置構建路徑”。 ![How to Download and Installation JUnit](https://img.kancloud.cn/17/58/1758851c151db449e88aa8f194077f3e_528x175.png "How to Download and Installation JUnit") **步驟 2)** Java 構建路徑窗口如下所示。 在該窗口中,轉到“庫”選項卡以查看所有 jar 文件。 在 jar 文件樹視圖中,您需要查找以 JUnit 開頭的 jar 文件名。 擴展 JUnit 庫后,您將看到如下所示的 Java 庫: ![How to Download and Installation JUnit](https://img.kancloud.cn/8a/05/8a05145ebcb6795a0d263958169cf94f_294x213.png "How to Download and Installation JUnit") 現在,您準備將 JUnit 與 eclipse 一起使用。 ## 第 6 部分)驗證 JUnit 設置 您可以創建一個簡單的 JUnit 測試來驗證 JUnit 設置。 參見下面的測試類: **步驟 1)**創建一個名為 TestJUnit.java 的 Java 類,并提供一個簡單的 assert 語句。 ![How to Download and Installation JUnit](https://img.kancloud.cn/80/26/8026955d12cf3c3c734e1f19bc4fb89d_429x163.png "How to Download and Installation JUnit") ``` package guru99.junit; import org.junit.Test; import static org.junit.Assert.assertEquals; public class TestJunit { @Test public void testSetup() { String str= "I am done with Junit setup"; assertEquals("I am done with Junit setup",str); } } ``` **步驟 2)**創建一個 Test Runner 類以執行上述測試。 ![How to Download and Installation JUnit](https://img.kancloud.cn/9f/87/9f87d9b06a4f2e88ca1c3d10e008e864_476x205.png "How to Download and Installation JUnit") ``` package guru99.junit; import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; public class TestRunner { public static void main(String[] args) { Result result = JUnitCore.runClasses(TestJunit.class); for (Failure failure : result.getFailures()) { System.out.println(failure.toString()); } System.out.println("Result=="+result.wasSuccessful()); } } ``` **步驟 3)**要對執行測試,請執行以下步驟: 1. 右鍵單擊 TestRunner.java,然后單擊“運行方式”,如下所示 2. 單擊“運行方式”后,將打開另一個窗口,單擊“ 1 JUnit Test”,如下所示: ![How to Download and Installation JUnit](https://img.kancloud.cn/79/22/792275a8b7e44cd26409f2bbf3135def_558x539.png "How to Download and Installation JUnit") **步驟 4)**這是測試的輸出或結果。 如果執行成功,它將在其前面顯示一個綠色的復選標記。 [![How to Download and Installation JUnit](https://img.kancloud.cn/02/55/02558397e83ff71a440e1736834c1fb9_335x401.png "How to Download and Installation JUnit") ](/images/junit/051716_0555_HowtoDownlo18.png) 單擊以下載上面的代碼以進行測試。
                  <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>

                              哎呀哎呀视频在线观看