Dashboard > OpenSource Project > ... > JUnit > JUnit Intro - Setup and configuration
OpenSource Project Log In   View a printable version of the current page.
JUnit Intro - Setup and configuration
Added by zach14c, last edited by swanky on Sep 19, 2004  (view change)
Labels: 
(None)

Reference: JavaWorld,caterpillar
  1. Download JUnit
    要設定JUnit,請先至JUnit官方網站下載JUnit3.8.1.zip,下載後解開壓縮檔,當中會含有junit.jar檔案,將這個檔案複製至您所要的資料夾中,然後設定CLASSPATH,例如:
     
    set classpath=%classpath%;INSTALL_DIR\junit3\junit.jar
    


    如果是Windows 2000/XP,請在[系統內容/進階/設定環境變數]中設定[系統變數]中的CLASSPATH,如果沒有就自行新增,像是:


  2. Sample Test
    • 文字模式測試範例
      java junit.textui.TestRunner junit.samples.AllTests
      
    • AWT圖形模式測試範例
      java junit.awtui.TestRunner junit.samples.AllTests
      
    • SWING圖形模式測試範例
      java junit.swingui.TestRunner junit.samples.AllTests
      

      當執行Swing的測試模式後,將會如以下畫面:



  3. IDE
    如果您使用Eclipse整合開發環境(IDE),在Eclipse中內含JUnit套件,如果在使用它的話,請在Package Explorer中的頂層專案名稱上按右鍵執行[properties],在[Java Build Path]的[libraries]標籤頁中按[Add JARs...],選擇junit.jar的所在位置將之加入,Eclipse是將之放置在plugins\org.junit_3.8.1中:

    設定好之後在Package Explorer中就會出現JUnit套件相關資訊,接下來您就可以直接在Eclpise中新增TestCase文件。

Other Resources:

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.1.5a Build:#411 Mar 16, 2006) - Bug/feature request - Contact Administrators