Model-based automated testing of JavaScript Web applications via longer test sequences

Pengfei Gao, Yongjie Xu, Fu Song, Taolue ChenFrontiers of Computer Science 2019 · DOI

Introduction

JavaScript's dynamic and event-driven nature presents significant challenges for automated testing. Traditional tools often struggle to reach complex logic buried deep within user interaction sequences, leading to a "coverage ceiling." A new approach, implemented in the tool LJS, demonstrates that generating significantly longer event sequences can break through these limitations and achieve superior code coverage.

The Problem: The Coverage Ceiling

Automated testing for JavaScript typically involves generating sequences of events like clicks and form inputs. Existing state-of-the-art tools often employ breadth-first search (BFS) strategies. Due to the exponential growth of possible event combinations, these tools are frequently restricted to short sequences (typically fewer than 6 events). However, many critical application states—such as multi-step processes or specific game conditions—require dozens of interactions to trigger. Consequently, BFS-based tools fail to explore deep code paths.

Methodology: The LJS Framework

LJS addresses the state explosion problem and the depth limitation through a multi-stage model-based approach.

The LJS framework architecture, illustrating the flow from source code to coverage report.
  1. Static Analysis: LJS identifies DOM event dependencies to determine which actions might influence the execution of others.
  2. Model Construction (FSM): The tool builds a Finite State Machine (FSM) using coarse-grained state abstraction. By ignoring irrelevant "implicit" DOM attributes that don't affect application logic, LJS creates a manageable model that avoids the state explosion common in finer-grained approaches.
  3. Weighted Event Selection: Exploration is guided by a strategy that prioritizes less-frequently executed events and those with direct dependencies on the previous action.
  4. Long Sequence Generation: Instead of BFS, LJS performs long random walks on the FSM, comfortably generating sequences exceeding 100 events.

Evaluation and Results

The researchers evaluated LJS against 21 benchmarks, including complex applications like Tetris and Sokoban.

LJS achieved an average line coverage of 86.4% within 10 minutes, outperforming the previous state-of-the-art tool, JSDEP, by 5.4%. The advantage was most pronounced in larger applications, where LJS provided 11-18% higher coverage.

Comparison of code coverage over time between LJS and JSDEP on the 'pearlski' benchmark.

As shown in the performance graphs, LJS not only achieves higher total coverage but often reaches its peak coverage significantly faster than its competitors. Experiments also confirmed that increasing the maximum sequence length directly correlates with improved code coverage, validating the core hypothesis of the research.

Conclusion

LJS demonstrates that long test sequences, supported by smart state abstraction and dependency-aware event selection, are highly effective for testing complex JavaScript applications. Future work will focus on refining static analysis precision and integrating more advanced data generation techniques to further enhance fault detection capabilities.

Summary updated

BibTeX
@article{gao2019model,
  author = {Pengfei Gao and Yongjie Xu and Fu Song and Taolue Chen},
  title = {{Model-based automated testing of JavaScript Web applications via longer test sequences}},
  journal = {Frontiers of Computer Science},
  year = {2019},
  doi = {10.1007/s11704-020-0356-7},
}
Figure