CodePro is a
premier Java software testing tool for Eclipse developers who are concerned
about improving software quality and reducing developments costs and schedules.
In this post, I am going to explain basics on how to use CodePro.
1. What
CodePro Offers
Code
Analysis
JUnit Test
Generation
Metrics
Code
Coverage
Dependency
Analysis
Similar Code
Analysis
JUnit Test
Editor
2. Install
codePro in eclipse
Get the
latest codePro from
https://developers.google.com/java-dev-tools/download-codepro
and install
it in eclipse.
Step 1: Goto Help -> Install New Software
Work with
the following URL.
Once
installation done successfully, Restart the eclipse. You are done.
After
restarting eclipse, you can able to see CodePro menu.
3. Code Audit
Code Audit
is a detailed analysis of code in a project to find bugs, violations of
programming practices etc., By auditing code, you can reduce the bugs before
delivering the product.
You can
perform code audit for a java project using codePro.
I created a
project named “codePro” in eclipse. It has “Main.java” file in it.
Main.java
package codePro; public class Main { public int getSum(int a, int b){ return (a+b); } public static void main(String args[]){ } }
To perform
code audit on the project “codePro”. Right click on the project, CodePro Tools
-> Audit code using.
Select
CodePro Default and press OK.
CodePro
apply audit rules and perform the audit. You can see the audit results in audit
tab.
CodePro
provides number of audit rule sets, you can select one by your choice.
CodePro
-> Preferences -> audit
Select one
of the audit set and press ok.
4. Dynamically
Auditing code
By using
CodePro, you can audit the code dynamically. By using this facility, developer
can audit the code while developing itself.
By default,
dynamic auditing facility is disabled. To enable dynamic auditing code
facility, CodePro -> Preferences -> audit
Click on
Dynamic Auditing menu.
Including/Excluding
resources follow ant pattern, For example, adding the pattern
"**/com/google/**/*" to the inclusion list would include any files in
the com.google package hierarchy. Likewise, adding the
"**/generated/**/*" pattern to the exclusion list would cause any
file in a package with "generated" in its path to be excluded from
dynamic auditing
5. Generate
Report
You can
generate report for auditing results. Right click on audit results ->
Generate Report -> (Select any one option). It saves the results in html
format. The audit results can be grouped by audit rule, category (audit rule
group), severity, resource or author.
6. Junit test
case generation
By using
codePro, you can generate junit test cases for a java class. To generate a test
case for given class, right click on the package/class -> CodePro Tools
-> Generate Test Cases.
Note:
If you
generate test case for Main.java, which is in the package com.sample and in the project
codeProTutorial, then new project codeProTutorialTest is created and
MainTest.java file is placed in com.sample package of the project package codeProTutorialTest.
You can
tweak number of option like generating javadoc cmments for test cases, maximum
number of test cases for a method etc., To tweak junit test options.
CodePro->Preferences->Junit
Referred Articles
No comments:
Post a Comment