A unit testing method and apparatus

By randomly generating primary key values ​​in unit tests, the problem of test failures caused by primary key conflicts during concurrent execution is solved, thus improving the efficiency and accuracy of unit tests.

CN115470147BActive Publication Date: 2026-07-21AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
AGRICULTURAL BANK OF CHINA
Filing Date
2022-10-19
Publication Date
2026-07-21

Smart Images

  • Figure CN115470147B_ABST
    Figure CN115470147B_ABST
Patent Text Reader

Abstract

The application provides a unit test method and device, and the test case including bottom data, test objects and assertions is constructed in advance according to preset variable rules; before the test case is executed, the value format of the primary key field conforming to the preset variable rules is obtained by analyzing the test case, and a random string is generated as the value of the primary key field according to the value format of the primary key field, so that the instantiated test case with unique primary key value is obtained. The primary key value conforming to the preset variable rules is randomly generated every time the unit test is executed, the primary key values of all bottom data, test objects and assertions in the same test case in the same unit test are consistent, the primary key values of the same test case in different unit tests are different, the problem that the unit test fails due to the primary key conflict in concurrent execution is avoided, and the unit test efficiency is effectively improved.
Need to check novelty before this filing date? Find Prior Art