Java Testing

Java Code Testing

Locating and fixing performance problems during source code development time is arguably the cheapest way to resolve problems. As your project goes past the development phase, in to testing and deployment, the cost of fixing problems grows exponentially. By conducting source code analysis and successfully identifying and correcting all such issues, software developers can eliminate the risk and potential costs early in the software development cycle.
We will try to understand few important aspects with Java Code Testing. Following document will help you understand what Java Code Testing means, why Java Code Testing is required and how you can successfully implement Java Code Testing for your Java applications using AppPerfect.



What is Java Code Testing?

During the development phase of an application, developers are faced with several challenges and have to consider various scenarios. To tackle the challenges without compromising on both performance and robustness of the application the developer very often comes across various issues while coding, such as.

  • How stable is my code?
  • Is the code optimized for best performance?
  • Does it follow agreed upon coding rules and standards?
  • Will there be any memory leaks?
  • Will the application be portable across multiple platforms?
  • Will the application work across the globe?
  • Will the application work consistently across 32-bit and 64-bit systems?
  • Does the code follow correct object oriented principles?
  • Is there any unused code, variables and so on... in the application?

Such issues if not detected in the early stages of the development cycle, can prove to be extremely expensive by way of unsatisfied customers, damage to the reputation and profile of the organization and extended hours of identifying issues and correcting them.

Java Code Testing involves testing your java source code against industry standard coding rules and ensuring that your java source is stable, optimized, consistent, portable and is compliant with coding standards. Automated Java Code Testing is more efficient and less error prone as compared to manual code reviews. Java Code Testing accomplishes a thorough and accurate review that checks for all defined cases. An automated Java Code Testing boosts development, saves cost and enhances the application quality by performing a test function or code review with greater consistency and in much lesser time. Performing such accurate reviews manually is tiresome, tedious and expensive. Automated Java Code testing also gives the ability and flexibility to a project manager to enforce coding standards and statistical quality control measures. The indicators of code size, complexity, and density can be computed using automated Java Code testing, which helps in the quality control of the code.



Java Code Testing with AppPerfect

An organization needs to implement various procedures that will minimize coding issues. Very often organizations depend on Manual Code Reviews which can be very time consuming, tedious and most often neglected. They also depend on the availability and individual skills of programmers which will differ from person to another, leading to compromises on consistency. An automated code review hence becomes a necessity for a software development organization. AppPerfect Java Code Test automates the code review both efficiently and consistently and without much overhead in terms of costs and resources.

AppPerfect Java Code Test is found to be most affordable, cost effective, efficient, reliable and accurate solution by its customers. We will now try to understand how you can successfully implement Java Code Testing for your Java application using AppPerfect Java Code Test.

Setting up your Java Application for Code Testing :

The first step in code analysis is to setup a New Java Code Test Project. Follow the steps below to create a new project.

  1. Start AppPerfect Java Code Test product and select File -> New.. menu option to create a New Java Code Test project. For details on New Project creation refer to Creating a New Project chapter. For details on configuring project properties refer to Setting Project Properties chapter.
  2. Provide the Name of the project and select the "Source" tab to configure Source Code to test. In this tab you need to configure the source settings for your application. You can select to add complete source folder for analysis or can add selected files. You can analyze both Java as well as JSP files.

    Java Code Testing : Configuring Source Settings
  3. Once you are done setting up project, select Project -> Run menu option to start analyzing source code for your Java application. For details refer to Code Analyzing a Project chapter.
Apply Over 750 Industry Standard Coding Rules:

AppPerfect's Code Testing tool applies over 750 built-in rules while analyzing your source code. These rules are categorized into various categories like optimization, portability, i18n, possible bugs, coding standards etc. You can create Custom Rule Configuration for your project and select the rules your desire to validate for your source.

To create custom Rule Configuration select the Project -> Rules Manager... menu option. This will launch Rules Manager dialog. By default Standard Rules configuration is applied. You can create a New Rules Configuration and select the rules you wish to apply.

Java Code Testing : Rules Configuration
Support for Custom Coding Rules:

While AppPerfect Java Code Test provides a rich set of pre-defined coding rules, at times you may find it necessary to define your own custom rules. AppPerfect Java Code Test is fully extensible and you can define your own custom coding rules which you need to apply on your project. You need to write a Java Rule Class to create your own Coding Rule. For details on how to create a custom rule refer to Creating Custom Rules chapter.

Once the rule class is ready, it may be added to AppPerfect Java Code Test by following these steps:

  1. Invoke the Rules Manager by selecting Project -> Rules Manager... in the menubar.
  2. Select File -> New Rule...
  3. Specify the rule class in the 'Validators' field.
  4. Specify the ID and Name for the rule.
Java Code Testing : Custom Rules Configuration
Support for JSP Code Analysis:

AppPerfect Java Code Test also provide support for analysing JSP source code. Some of the coding rules are specially tailored for analysing JSP source. To enable analysis of JSP source select Project -> Properties.. menu option and select the option to Analyze JSP Files. Also provide the Document root for your web application. Document Root is the root directory of your web application. Its basically the location of WEB-INF folder in your web application.

Automatically Fix Coding Rule Violations:

AppPerfect Java Code Test provides support for automatically fixing rule violations. Once errors are detected, AppPerfect can automatically fix over 180 types of violations. You can simply review and approve the changes. It is recommended to take backup of your source code before applying Auto-fix. To enable Auto-Fix for rule violations during analysis select Project -> Properties.. menu option and select the option to Perform Auto-Fix of rules during Analysis. You can also apply Auto-fix later once the analysis is complete. To Auto-fix code after analysis is over select the Auto Fixable Violations tab. Right click on the Violated Rule and it will show a popup menu showing option to Fix Rule Violation.

Java Code Testing : Auto-Fix Rules Violations
Extensive Metrics Information:

AppPerfect thoroughly analyzes your Java Code and provides detailed information about various metrics for the source code like number of code lines, comments lines, complexities of methods, number of methods, Method Parameters, Nested Block Depth etc. This information is vital for Java code compliance. To view all the Code Metrics collected, select the Metrics tab.

Java Code Testing : Metrics
Informative and User Friendly Reports:

AppPerfect Java Code Test provides reports that help you pin point problems in your code. These reports are available through the UI and can be exported into various formats like HTML, PDF, CSV, XLS, XML etc. To export reports to different formats just right click on the view on right hand side and select the option to Export from the popup menu.
AppPerfect Java Code Test provides informative reports as a result of code analysis. You can view vilations Category wise as well as Severity wise helping you fixing the crucial violations first. To track the violations developer wise you can check Developer Wise reports where violations are reported developer wise.

Java Code Testing : Reports
Java Code Testing can Run Unattended in Automated Manner:

With AppPerfect's Code Testing solution you can run lengthy code reviews unattended. Tests can be scheduled to run overnight and developers can analyze the results of execution next morning. As a result you save time and improve efficiency and can concentrate on other important tasks while scheduled reviews run in background. To schedule code testing you require AppPerfect Test Manager product. Once you have Test Manager installed you need to first configure Java Code Test to enable connection to Test Manager server. To configure the Test Manager connection select Tools -> Options -> Server Connections -> Test Manager Settings and provide the host:port information for the machine where Test Manager is installed. Once you have connection configured you can save the Java Code Test Project to Test Manager using File -> Save in Test Manager menu option. Once test is saved to Test Manager you can schedule Test Execution using Tools -> Schedule Project menu option.

Test Scheduler

For details on creating and executing Test Schedules using Test Manager Web-UI refer to Schedules chapter.

Java Code Testing with Team Sharing Support:

Test Engineers can share the Code Testing results with different members in the team. Code Testing results can be shared with developers which they can use to track the coding issues in application. AppPerfect supports integration with Subversion (SVN) version control system. For details on integration with Subversion server refer to Team Server Configuration chapter.

IDE Integration Support:

IDE Integration is a highly useful feature in AppPerfect products. Once product is integrated in IDE you can start IDE and can execute Java Code Testing for your Java / J2EE source from within IDE. You can integrate AppPerfect applications with Eclipse, IBM Rational Application Developer (RAD), NetBeans, IntelliJ Idea, JBuilder, Oracle JDeveloper and BEA Workshop studio.
Select Tools -> IDE Integration menu option to integrate with any of the supported IDEs. For details on integration with IDE refer to IDE Integration chapter.

IDE Integration
Integrate Java Code Testing with your Daily Build Process with ANT Script and Command line Support:

AppPerfect supports integration with build process smoothly. You just need to export Java Code Testing project as ANT Script or Command Line script and then you can execute these exported scripts from your build process. This way you can ensure that each build is analysed before final deployment. To Export project as Ant Script select Tools -> Export Project as ANT Script... menu option. For details on ANT script execution refer to ANT Script Execution chapter.

Ant Script Export
Conclusion :

AppPerfect Java Code Test helps you diagnose and resolve coding issues. AppPerfect Java Code Test offers you a variety of options to test and optimize your application and make it free of bugs and problems. AppPerfect Java Code Test is a static Java code analysis software designed to perform the two key tasks: Automate Java Code review and Enforce Good Java Coding Practices. AppPerfect Java Code Test can analyze your Java and Java Server Pages (JSP) source code and implements over 750 Java coding rules to check your code for consistency, portability, stability, optimisation and coding standards. AppPerfect Java Code Test is found to be most affordable, cost effective, efficient, reliable and accurate code review solution by its customers. In case you have not yet tried AppPerfect Java Code Test, Download Now and give it a try today.