Java Defects

12

Click here to load reader

description

Learn how to prevent more Java defects by applying static code analysis, flow analysis, unit testing, and runtime error detection in concert.

Transcript of Java Defects

Page 1: Java Defects

Prevent All Java Software Defects with a Single Tool

2010

Parasoft Proprietary and Confidential

Page 2: Java Defects

Parasoft Proprietary and Confidential

Automated Analysis Techniques

Application Tracing for Unit TestsPattern-Based Static Code AnalysisRuntime Error DetectionAutomated Unit Test GenerationData Flow AnalysisRegression Testing

Page 3: Java Defects

Parasoft Proprietary and Confidential

JPetStore Java EE Tutorial

Spring-BasedHSQL DatabaseJSP Web InterfaceApache Tomcat

Introducing the Java Web App

Page 4: Java Defects

Parasoft Proprietary and Confidential

Similar Items not Aggregating in Shopping Cart

Add one item to the cartAdd the same item againExpected: a single line item with quantity 2Found: 2 line items each with quantity 1

The Problem Report

Page 5: Java Defects

Parasoft Proprietary and Confidential

Application Tracing for Unit Tests

Record internal method calls inside the running application when the problem occursReplicate the problem in a JUnit testAlter the JUnit test to assert the correct behaviorNow possible solutions can be tested quickly without redeploying the web application

Page 6: Java Defects

Parasoft Proprietary and Confidential

Pattern-Based Static Analysis

Quick scan to list possible problemsFixing violations prevents certain classes of errorsEach source file is analyzed separatelyStatic analysis categories include:

Logical ErrorsAPI MisuseTypographical ErrorsSecurityThreads and SynchronizationPerformance and Optimization

Page 7: Java Defects

Parasoft Proprietary and Confidential

Runtime Error Detection

Check for anti-patterns at runtime in the applicationViolations are presented in the context of real-world data values to stress their importanceRuntime error categories include:

Threads and SynchronizationPerformance and OptimizationApplication CrashesFunctional ErrorsSecurity

Page 8: Java Defects

Parasoft Proprietary and Confidential

Automated Unit Test Generation

Test code branches not covered by the application-level testCombine these unit tests with runtime error detection to check the new execution pathsBuild a baseline regression test suite

Page 9: Java Defects

Parasoft Proprietary and Confidential

Data Flow Analysis

Simulate hypothetical execution pathsDetect possible errors along those pathsData flow analysis error categories include:

ExceptionsOptimizationResource LeaksAPI misuseSecurity

Page 10: Java Defects

Parasoft Proprietary and Confidential

Regression Testing

Capture current behavior of covered code pathsWhether the current behavior is right or wrong

Alert when code modifications cause a change in behaviorDevelopers can then mark JUnit assertions as correct behavior to increase the severity if those assertions fail in the future

Page 11: Java Defects

Parasoft Proprietary and Confidential

Java Software Problems

FunctionalThread concurrencyPerformanceRegressionRequirement TestingCode Review

Page 12: Java Defects

Parasoft Proprietary and Confidential

Comparable Tools

Static AnalysisData Flow AnalysisUnit Test Framework (with Test Engineer)ProfilerQA Functional TesterCode ReviewCode Metrics MeasurementCode Duplication DetectionTask Management