您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源單元測(cè)試工具 >
在eclipse中使用findbug
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2013/2/18 13:32:48 ] 推薦標(biāo)簽:

  1. Run FindBugs Automatically開關(guān)

     當(dāng)此項(xiàng)選中后,F(xiàn)indBugs將會(huì)在你修改Java類時(shí)自動(dòng)運(yùn)行,如你設(shè)置了Eclipse自動(dòng)編譯開關(guān)后,當(dāng)你修改完Java文件保存,F(xiàn)indBugs會(huì)運(yùn)行,并將相應(yīng)的信息顯示出來(lái)。

     當(dāng)此項(xiàng)沒(méi)有選中,你只能每次在需要的時(shí)候自己去運(yùn)行FindBugs來(lái)檢查你的代碼。

  2. Minimum priority to report選擇項(xiàng)

     這個(gè)選擇項(xiàng)是讓你選擇哪個(gè)級(jí)別的信息進(jìn)行顯示,有Low、Medium、High三個(gè)選擇項(xiàng)可以選擇,很類似于Log4J的級(jí)別設(shè)置啦。 比如:

     你選擇了High選擇項(xiàng),那么只有是High級(jí)別的提示信息才會(huì)被顯示。

     你選擇了Medium選擇項(xiàng),那么只有是Medium和High級(jí)別的提示信息才會(huì)被顯示。

     你選擇了Low選擇項(xiàng),那么所有級(jí)別的提示信息都會(huì)被顯示。

  3. Enable bug categories選擇項(xiàng)

     在這里是一些顯示Bug分類的選擇:

     Correctness關(guān)于代碼正確性相關(guān)方面的

     Performance關(guān)于代碼性能相關(guān)方面的

     Internationalization關(guān)于代碼國(guó)際化相關(guān)方面的

     Multithreaded correctness關(guān)于代碼多線程正確性相關(guān)方面的

     Style關(guān)于代碼樣式相關(guān)方面的

     Malicious code vulnerability關(guān)于惡意破壞代碼相關(guān)方面的

     比如:如果你把Style的檢查框去掉不選擇中它,那么與Style分類相關(guān)的警告信息不會(huì)顯示了。其它的類似。

  4. Select bug patterns to check for選擇項(xiàng)

     在這里你可以選擇所要進(jìn)行檢查的相關(guān)的Bug Pattern條目

     可以從Bug codes、Detector name、Detector description中看到相應(yīng)的是要檢查哪些方面的內(nèi)容,你可以根據(jù)需要選擇或去掉相應(yīng)的 檢查條件。

  總結(jié)

  此插件的功能很不錯(cuò),可以幫助我們提升Java代碼的編寫能力,寫出更加安全可靠的代碼。建議使用或加在Ant里進(jìn)行持續(xù)構(gòu)建。

  現(xiàn)在,你可以馬上拿出你已經(jīng)開發(fā)的一個(gè)項(xiàng)目,檢查一下你的代碼有沒(méi)有問(wèn)題了。
剛剛發(fā)現(xiàn)了另外一種更加簡(jiǎn)單的安裝方法,詳情見(jiàn):http://findbugs.cs.umd.edu/eclipse
   If you have previously installed a version of the FindBugs plugin prior to mid-May, 2006, then you should remove it first. Simply remove the de.tobject.findbugs_0.0.n directory from Eclipse's plugins directory.

To install the FindBugs plugin:

  1. In Eclipse, click on Help -> Software Update -> Find and Install...
  2. Choose the Search for new features to install option, and click Next.
  3. Click New Remote Site.
  4. Enter the following:
         * Name: FindBugs update site
         * URL: one of the following (note: no final slash on the url)
               o http://findbugs.cs.umd.edu/eclipse for official releases
               o http://findbugs.cs.umd.edu/eclipse-candidate for candidate releases and official releases
               o http://findbugs.cs.umd.edu/eclipse-daily for all releases, inculding developmental ones
     and click OK.
  5. "FindBugs update site" should appear under Sites to include in search.
     Click the checkbox next to it to select it, and click Finish.
  6. You should see FindBugs Feature under Select features to install.
     (You may have to click on one or two triangles to make it visible in the tree.)
     Select the checkbox next to it and click next.
  7. Select the I accept option to accept the license and click Next.
  8. Make sure the location is correct where you're installing it. The default (your workspace) should be fine. Click Finish.
  9. The plugin is not digitally signed. Go ahead and install it anyway.
 10. Click Yes to make Eclipse restart itself.

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