Vidock: A Tool for Impact Analysis of Aspect Weaving on Test Cases

Romain Delamare, Freddy Munoz, Benoit Baudry, Yves Le TraonICTSS 2010 · OpenReview

Abstract

The addition of a cross-cutting concern in a program, through aspect weaving, has an impact on its existing behaviors. If test cases exist for the program, it is necessary to identify the subset of test cases that trigger the behavior impacted by the aspect. This subset serve to check that interactions between aspects and the base program do not introduce some unexpected behavior. Vidock performs a static analysis when aspects are compiled with a program to select the test cases impacted by the aspects. It leverages the pointcut descriptor to locate the set of methods impacted by aspects and then selects the test cases that can reach an impacted method. This static analysis has to perform over-approximations when the actual point where the aspect is executed can be computed only at runtime and when test cases call polymorphic objects. We measure the occurrence of these assumptions in 4986 projects containing 498 aspects to show they have a limited impact. Then, we run experiments with Vidock on 5 cases studies and analyze the impacts that different types of aspects can have on test cases.

Introduction

In Aspect-Oriented Programming (AOP), developers use aspects to implement cross-cutting concerns like logging, security, or transaction management. These aspects are "woven" into the base code at specific points called joinpoints. However, weaving an aspect can change the behavior of the existing program, potentially invalidating existing test suites.

Running an entire suite of thousands of tests after every change is time-consuming. While dynamic analysis can identify impacted tests by executing them, it is a heavy process. Vidock addresses this by using static analysis to predict impact without executing code, identifying which JUnit test cases are affected when AspectJ aspects are woven into a Java program.

Methodology

Vidock employs a two-step static analysis process to identify impacted test cases.

1. Impacted Method Selection

The tool first identifies which methods in the base program will have aspects woven into them. It uses the Pointcut Descriptor (PCD)—the "address" an aspect uses to find its target—to locate these methods. To ensure no potential impact is missed, Vidock uses over-approximation for "dynamic" pointcuts (e.g., cflow), treating them as if they are always triggered.

2. Test Case Reachability

Using the Spoon library, Vidock constructs a Static Call Graph (SCG) for every test case. It then performs a depth-first search to determine if a path exists from the test case to any impacted method.

Overview of the Vidock impact analysis process, showing the selection of impacted methods and the construction of test-driven Static Call Graphs (SCGs).

Handling Polymorphism

Static analysis often struggles with polymorphism because the specific subclass method called may only be known at runtime. Vidock handles this by adding "potential call" edges to the SCG for every possible overriding method in the inheritance tree. This ensures the analysis remains conservative and safe.

Example of a Static Call Graph (SCG) where solid lines represent direct calls and dashed lines represent potential calls due to polymorphism.

Evaluation and Results

The approach was validated using a large-scale study of 4,986 projects containing 498 aspects to assess the prevalence of complex features like method overriding and dynamic pointcuts. Additionally, five case studies (Introduction, Bean, Telecom, Tetris, and a custom Auction system) were used to measure performance.

Key Findings

  • 100% Recall: Vidock successfully identified every test case actually impacted by aspects in all experiments. This "safety first" approach ensures no regressions go unnoticed.
  • High Precision: Precision reached 100% for most projects. In the complex Auction system, precision was lower (63-79%) due to heavy use of the State design pattern, which triggered more polymorphic over-approximations.
  • Efficiency: In most scenarios, Vidock demonstrated that less than 20% of the test suite required re-running, significantly reducing the developer's test-code-debug cycle.
  • AOP Usage Patterns: The study revealed that 83% of pointcuts are purely static and only 6% of methods are typically overridden, suggesting that over-approximation does not lead to an unmanageable number of false positives in practice.

Conclusion

Vidock provides a robust, static alternative to dynamic impact analysis for AOP. By prioritizing recall through over-approximation, it offers developers a reliable way to prune test suites. Future work may involve classifying aspects by their behavioral impact to provide deeper insights into why specific tests might fail.

Summary updated

Abstract

The addition of a cross-cutting concern in a program, through aspect weaving, has an impact on its existing behaviors. If test cases exist for the program, it is necessary to identify the subset of test cases that trigger the behavior impacted by the aspect. This subset serve to check that interactions between aspects and the base program do not introduce some unexpected behavior. Vidock performs a static analysis when aspects are compiled with a program to select the test cases impacted by the aspects. It leverages the pointcut descriptor to locate the set of methods impacted by aspects and then selects the test cases that can reach an impacted method. This static analysis has to perform over-approximations when the actual point where the aspect is executed can be computed only at runtime and when test cases call polymorphic objects. We measure the occurrence of these assumptions in 4986 projects containing 498 aspects to show they have a limited impact. Then, we run experiments with Vidock on 5 cases studies and analyze the impacts that different types of aspects can have on test cases.
BibTeX
@inproceedings{delamare2010vidock,
  author = {Romain Delamare and Freddy Munoz and Benoit Baudry and Yves Le Traon},
  title = {{Vidock: A Tool for Impact Analysis of Aspect Weaving on Test Cases}},
  booktitle = {ICTSS},
  year = {2010},
  url = {https://openreview.net/forum?id=rl-N2f63Xlc},
}
Figure