CodeCover初体验

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

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

  CodeCover初体验

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

  CodeCover初体验

 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.

  CodeCover初体验

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

CodeCover初体验

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

  CodeCover初体验

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.

CodeCover初体验

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

CodeCover初体验

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.

CodeCover初体验

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.

CodeCover初体验

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

4. Test Sessions View

CodeCover初体验

5. Coverage View

CodeCover初体验

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

CodeCover初体验

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

CodeCover初体验

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

上一篇:kaggle learn python


下一篇:redis实战笔记(6)-第6章 使用 Redis构建应用程序组件