IP Library › Granted Patent US 10,372,594
Granted Patent B2
US 10,372,594 · App. 15/271,347 · Granted Aug 6, 2019

Method and device for retrieving test case based on code coverage

Inventors: Bin Xu (Shanghai, CN); Yue Li (Shanghai, CN); Neil Yongjing Wang (Shanghai, CN); Sam Lei Sun (Shanghai, CN); Edward Zhibin Xu (Shanghai, CN)
Assignee: EMC IP Holding Company LLC
G06F11/3688G06F11/368G06F11/3676G06F11/3692
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 10,372,594
App. No.
15/271,347
Granted
Aug 6, 2019
Kind
B2
Abstract

Embodiments of the present invention relate to a method and a device for obtaining test cases based on a code coverage. The method comprises creating a mapping between source code and test cases based on a code coverage; and obtaining, in response to a change in the source code, the test cases for the change based on the mapping. The device comprises: a creating module configured to create a mapping between source code and test cases based on a code coverage; and an obtaining module configured to, in response to a change in the source code, obtain a test case for the change based on the mapping. Through such method and device, the embodiments of the present invention can obtain test cases as few as possible to cover the changed source code.

Claims (57)

1. A method for testing a software program, comprising:

creating a mapping table expressing a mapping between source code of the software program and test cases based on code coverage, wherein the source code is stored within a source code repository on a data storage system and the source code includes classes and functions, each class including one or more of the functions, the mapping table including a plurality of mapping entries each associating a respective test with a corresponding function and a corresponding class that includes the function;

in response to a change in the source code, obtaining a test case for the change based on the mapping in the mapping table, wherein the test case is selected from a plurality of test cases available to test the source code by (1) in a first case in which a function has changed, obtaining a first test case based on a first association of the first test case with the function in the mapping table, and (2) in a second case in which a class including the function has changed, obtaining a second test case based on a second association of the second test case with the class in the mapping table; and

executing the software program according to the obtained test case to test the change in the source code,

wherein the function is a first function and the first association associates the first test case with both the first function and the class, and wherein the mapping table includes one or more additional entries making a second association between the second test case, the class, and a second function of the class, such that selection of the second test case includes coverage of the class but not of the first function of the class.

2. The method according to claim 1 , wherein the creating a mapping between source code and test cases based on a code coverage comprises:

generating a run report after running the test cases on the source code using a code coverage tool; and

obtaining a mapping between the source code and the test cases based on the run report.

3. The method according to claim 2 , wherein the generating a run report after running the test cases on the source code using a code coverage tool comprises:

after running each of the test cases on the source code, generating the run report for each of the test cases using the code coverage tool.

4. The method according to claim 2 , wherein the obtaining a mapping between the source code and the test cases based on the run report comprises:

creating, based on the run report, mapping tables between the test cases and line numbers, function names, class names and file names in the source code.

5. The method according to claim 4 , wherein the creating the mapping tables comprises:

performing information extraction on the run report generated after running each of the test cases to obtain a mapping table between each of the tests case and corresponding line numbers, function names, class names and file names in the source code.

6. The method according to claim 5 , wherein the obtaining a mapping table between each of the test cases and corresponding line numbers, function names, class names and file names in the source code comprises:

reading the run report to obtain the line numbers, function names, class names and file names of the source code; and

storing each of the test cases and the obtained line numbers, function names, class names and file names into a mapping table of a database.

7. The method according to claim 1 , wherein the creating mapping between source code and the test cases based on a code coverage comprises:

performing test cases in a test case repository for the source code to obtain the code coverage.

8. A computer-implemented device, comprising:

memory storing instructions; and

a processor coupled to the memory and operative to execute the instructions to form functional modules collectively operative to test a software program, the modules including:

a creating module configured to create a mapping table expressing a mapping between source code of the software program and test cases based on code coverage, wherein the source code is stored within a source code repository on a data storage system and the source code includes classes and functions, each class including one or more of the functions, the mapping table including a plurality of mapping entries each associating a respective test with a corresponding function and a corresponding class that includes the function;

an obtaining module configured to, in response to a change in the source code, obtain a test case for the change based on the mapping in the mapping table, wherein the test case is selected from a plurality of test cases available to test the source code, by (1) in a first case in which a function has changed, obtaining a first test case based on a first association of the first test case with the function in the mapping table, and (2) in a second case in which a class including the function has changed, obtaining a second test case based on a second association of the second test case with the class in the mapping table;

wherein the device is enabled to execute the software program according to the obtained test case to test the change in the source code,

and wherein the function is a first function and the first association associates the first test case with both the first function and the class, and wherein the mapping table includes one or more additional entries making a second association between the second test case, the class, and a second function of the class, such that selection of the second test case includes coverage of the class but not of the first function of the class.

9. The device according to claim 8 , wherein the creating module comprises:

a generating module configured to generate a run report after running the test cases on the source code using a code coverage tool; and

an obtaining module configured to obtain a mapping between the source code and the test cases based on the run report.

10. The device according to claim 9 , wherein the generating module configured to generate a run report after running the test cases on the source code using a code coverage tool comprises:

a generating module configured to generate a run report for each of the test cases using the code coverage tool after running each of the test cases on the source code.

11. The device according to claim 9 , wherein the obtaining module configured to obtain mapping between the source code and the test cases based on the run report comprises:

a creating module configured to create based on the run report a mapping table between the test cases and line numbers, function names, class names and file names in the source code.

12. The device according to claim 11 , wherein the creating module configured to create based on the run report a mapping table between the test cases and line numbers, function names, class names and file names in the source code comprises:

a performing module configured to perform information extraction on a run report generated after running each of the test cases to obtain a mapping table between each of the test cases and corresponding line numbers, function names, class names and file names in the source code.

13. The device according to claim 12 , wherein the performing module configured to perform information extraction on a run report generated after running each of the test cases to obtain a mapping table between each of the test cases and corresponding line numbers, function names, class names and file names in the source code comprises:

a reading module configured to read the run report to obtain the line numbers, function names, class names and file names of the source code; and

a storing module configured to store each of the test cases and the obtained line numbers, function names, class names and file names into a mapping table of a database.

14. The device according to claim 8 , wherein the creating module comprises:

an executing module configured to execute all test cases in a test case repository for the source code to obtain the code coverage.

15. The device according to claim 14 , wherein the executing module configured to execute all test cases in a test case repository for the source code to obtain the code coverage comprises:

an adding module configured to add a new test case into the test case repository for an uncovered part of the source code, if the test cases in the test case repository fail to cover the source code.

16. The device according to claim 8 , wherein the creating module comprises:

a storing module configured to store the mapping in a database modeled using a unitary modeling language.

17. A computer program product, comprising:

a non-transitory computer readable medium encoded with computer-executable code for testing a software program, wherein the code is configured to enable the execution of:

creating a mapping table expressing a mapping between source code of the software program and test cases based on code coverage, wherein the source code is stored within a source code repository on a data storage system and the source code includes classes and functions, each class including one or more of the functions, the mapping table including a plurality of mapping entries each associating a respective test with a corresponding function and a corresponding class that includes the function;

in response to a change in the source code, obtaining a test case for the change based on the mapping in the mapping table, wherein the test case is selected from a plurality of test cases available to test the source code, by (1) in a first case in which a function has changed, obtaining a first test case based on a first association of the first test case with the function in the mapping table, and (2) in a second case in which a class including the function has changed, obtaining a second test case based on a second association of the second test case with the class in the mapping table; and

executing the software program according to the obtained test case to test the change in the source code,

wherein the function is a first function and the first association associates the first test case with both the first function and the class, and wherein the mapping table includes one or more additional entries making a second association between the second test case, the class, and a second function of the class, such that selection of the second test case includes coverage of the class but not of the first function of the class.

18. The method according to claim 17 , wherein the creating a mapping between source code and test cases based on a code coverage comprises:

generating a run report after running the test cases on the source code using a code coverage tool; and

obtaining a mapping between the source code and the test cases based on the run report.

19. The method according to claim 18 , wherein the generating a run report after running the test cases on the source code using a code coverage tool comprises:

after running each of the test cases on the source code, generating the run report for each of the test cases using the code coverage tool.

20. The method according to claim 18 , wherein the obtaining a mapping between the source code and the test cases based on the run report comprises:

creating, based on the run report, mapping tables between the test cases and line numbers, function names, class names and file names in the source code.

Assignments (7)
RELEASE OF SECURITY INTEREST IN PATENTS PREVIOUSLY RECORDED AT REEL/FRAME (053546/0001) Recorded Jun 23, 2022
From: THE BANK OF NEW YORK MELLON TRUST COMPANY, N.A., AS NOTES COLLATERAL AGENT
To: DELL MARKETING L.P. (ON BEHALF OF ITSELF AND AS SUCCESSOR-IN-INTEREST TO CREDANT TECHNOLOGIES, INC.); DELL INTERNATIONAL L.L.C.; DELL PRODUCTS L.P.; DELL USA L.P.; EMC CORPORATION; DELL MARKETING CORPORATION (SUCCESSOR-IN-INTEREST TO FORCE10 NETWORKS, INC. AND WYSE TECHNOLOGY L.L.C.); EMC IP HOLDING COMPANY LLC
Reel/Frame 071642/0001 →
RELEASE OF SECURITY INTEREST IN PATENTS PREVIOUSLY RECORDED AT REEL/FRAME (043775/0082) Recorded May 20, 2022
From: THE BANK OF NEW YORK MELLON TRUST COMPANY, N.A., AS NOTES COLLATERAL AGENT
To: DELL PRODUCTS L.P.; EMC CORPORATION; EMC IP HOLDING COMPANY LLC
Reel/Frame 060958/0468 →
SECURITY AGREEMENT Recorded Apr 22, 2020
From: CREDANT TECHNOLOGIES INC.; DELL INTERNATIONAL L.L.C.; DELL MARKETING L.P.; DELL PRODUCTS L.P.; DELL USA L.P.; EMC CORPORATION; FORCE10 NETWORKS, INC.; WYSE TECHNOLOGY L.L.C.; EMC IP HOLDING COMPANY LLC
To: THE BANK OF NEW YORK MELLON TRUST COMPANY, N.A.
Reel/Frame 053546/0001 →
SECURITY AGREEMENT Recorded Mar 21, 2019
From: CREDANT TECHNOLOGIES, INC.; DELL INTERNATIONAL L.L.C.; DELL MARKETING L.P.; DELL PRODUCTS L.P.; DELL USA L.P.; EMC CORPORATION; FORCE10 NETWORKS, INC.; WYSE TECHNOLOGY L.L.C.; EMC IP HOLDING COMPANY LLC
To: THE BANK OF NEW YORK MELLON TRUST COMPANY, N.A.
Reel/Frame 049452/0223 →
PATENT SECURITY AGREEMENT (NOTES) Recorded Sep 6, 2017
From: DELL PRODUCTS L.P.; EMC CORPORATION; EMC IP HOLDING COMPANY LLC
To: THE BANK OF NEW YORK MELLON TRUST COMPANY, N.A., AS COLLATERAL AGENT
Reel/Frame 043775/0082 →
PATENT SECURITY AGREEMENT (CREDIT) Recorded Sep 6, 2017
From: DELL PRODUCTS L.P.; EMC CORPORATION; EMC IP HOLDING COMPANY LLC
To: CREDIT SUISSE AG, CAYMAN ISLANDS BRANCH, AS COLLATERAL AGENT
Reel/Frame 043772/0750 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Dec 13, 2016
From: XU, BIN; LI, YUE; WANG, NEIL YONGJING; SUN, SAM LEI; XU, EDWARD ZHIBIN
To: EMC IP HOLDING COMPANY LLC
Reel/Frame 040722/0590 →
Priority Claims (1)
CN 2015 1 0622723 · Sep 25, 2015 · national
Continuity (1)
Related Publication 20170132119A1 · May 11, 2017
Cited By (1)
US 12,450,150