Automated Baseline Generation and New Tags for the Qunit Testing Framework

This article explains how Qunar's Qunit testing framework was enhanced with automatic baseline generation and new tags—dataMode, dataHolder, dataAssert, and dbAssert—to simplify test case creation, maintenance, and verification while reducing reliance on external data services.

Qunar Tech Salon
Qunar Tech Salon
Qunar Tech Salon
Automated Baseline Generation and New Tags for the Qunit Testing Framework

Qunit is QuNar's automated interface testing framework that stores test cases in XML, enabling regression runs, but rapid project iteration and accumulating case volume created a need for a simpler, more maintainable automation approach.

The proposed solution introduces automatic baseline generation through three execution phases: the first run records service requests, database impacts, and response data; the second run replays the test without invoking data preparation services, comparing results to identify differing fields stored in ignore.xml; the third run executes the production code, removes ignored fields, and validates consistency against the recorded baseline.

Four new tags are added to support this workflow: dataMode switch (generate for debugging, assert for validation), dataHolder for capturing complex data preparation, dataAssert for automatic JSON response assertion, and dbAssert for automatic database state assertion. Each tag defines how data is recorded during the generate phase and compared during the assert phase, with example file naming conventions such as dataHolder_n_Record.xml, dataAssert_n_Recode.xml, and dbAssert_n_Recode.xml.

Implementation steps include upgrading the qunit-core JAR to version 1.1.1‑snapshot or later, adding the dataMode switch in qunit.properties (e.g., dataMode=generate or dataMode=assert), configuring the JDBC URL with &zeroDateTimeBehavior=round to avoid XML export errors for null dates, and enabling MySQL binlog with recommended settings:

log_bin=<binlog_path>
expire_logs_days=1
binlog_do_db=<target_database>
binlog_format=ROW

.

The article concludes that despite a busy workload, the team is committed to improving code quality and test coverage, and invites readers to share feedback and contributions.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Software Testingtest automationBackend testingQunitbaseline generationdataMode
Qunar Tech Salon
Written by

Qunar Tech Salon

Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.