码迷,mamicode.com
首页 > 其他好文 > 详细

CodeCover初体验

时间:2014-10-09 16:50:47      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   os   使用   ar   java   for   

国庆刚过完,闲来无事,就随便看看,顺便来了解下一些工具的使用,在工作中要用到的时候可以直接上手。

CodeCover是一个免费的白盒测试工具,主要测试代码、分支、循环、MC/DC 覆盖。支持为每个测试用例生成独立的报表,目前支持的语言有 Java 和 COBOL。本篇介绍CodeCover作为MyEclipse的插件时的使用。

官网:http://codecover.org/index.html

 

一. 下载安装

The CodeCover MyEclipse Plugin is installed using the standard Eclipse update mechanism:

  1. Start MyEclipse.
  2. From the main menu, select "Help", "Software updates", "Find and install...".

  bubuko.com,布布扣

  3. In the upcoming dialog, select "Search for new features to install" and click " "Next".

  bubuko.com,布布扣

 4. The list containing known update sites will be displayed. Create a new update site by clicking on "New Remote Site..." and enter the following information:

   Name: CodeCover Update Site
   URL:  http://update.codecover.org/

Select the newly created site, if not already selected, and click "Finish". Eclipse will now contact the CodeCover update site; this might take a moment depending on your network connection.

  bubuko.com,布布扣

 5. In the next dialog, you will see the list of features found on the update site; for now, CodeCover consists of only one feature. Select it for installation and click "Next".

bubuko.com,布布扣

 6. After the download has finished, Eclipse will ask you some questions about the license and installation, and prompt to restart the workbench. You should confirm the restart as not all CodeCover features are guaranteed to work if you simply click "Apply Changes".

  bubuko.com,布布扣

 

Now CodeCover for MyEclipse is installed! You can proceed to the CodeCover Eclipse walkthrough to learn how you can use it.

 

二.  使用

 1. Selecting the files to instrument

Open the Package Explorer view. Choose the Java Classes and Packages you want to instrument and open the context menu by right-clicking on the selected items. The menu item "Use For Coverage Measurement" allows you to toggle the instrumentation state of the selected items.

bubuko.com,布布扣

选中之后,此类前面就会有一个标记,如下图:

bubuko.com,布布扣

2.Enabling CodeCover for a Java project

Open the Properties of your project, e.g. by selecting the project in the Package Explorer and choosing the Properties menu item of the Project menu. Once the Properties are visible, select the CodeCover tab. This tab contains a checkbox which you use to enable/disable CodeCover for the project.

bubuko.com,布布扣

3.Running a Java project with CodeCover

Select the CodeCover tab and click on the "Run As"-"CodeCover Measurement " checkbox. Click the Run button to start the application. 

bubuko.com,布布扣

Once the execution of the application is finished, the gathered coverage data will be shown in the Coverage View.

 

4. Test Sessions View

bubuko.com,布布扣

5. Coverage View

bubuko.com,布布扣

Last Two View come from Menu(Windows)-Show View-Other:CodeCover

bubuko.com,布布扣

 最后再来工具查看对应的代码:

bubuko.com,布布扣

 

讲到这里,CodeCover已讲解完了,对它的基本使用已了解,待日后工作使用到的时候再去详细了解。

CodeCover初体验

标签:style   blog   http   io   os   使用   ar   java   for   

原文地址:http://www.cnblogs.com/yangxia-test/p/4013494.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!