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.
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
