# US 2016/0259713 A1 · Method and system for determining functional tests to execute based on code coverage

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2016/0259713 A1
- Document ID: US20160259713A1
- Status: Published application
- Kind: A1
- Application number: 14/638,442
- Filed: 2015-03-04
- Published: 2016-09-08
- Earliest claimed: 2015-03-04
- Assignees: VMware, Inc.
- Applicants: VMware, Inc.
- Inventors: Rekha BELUR
- Web page: https://patentgrep.com/patent/US20160259713A1

## CPC

- G06F 11/3676: {for coverage analysis}
- G06F 8/00: Arrangements for software engineering (testing or debugging G06F11/36; administrative, planning or organisation aspects of software project management G06Q10/06)
- G06F 11/3644: {by instrumenting at runtime}
- G06F 11/368: {for test version control, e.g. updating test cases to a new software version}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Techniques are disclosed for automatically determining tests to run on source code based on code coverage. In one embodiment, an extensible system takes as input a configuration file having pointers to an IP address of a server where tests are being run and a type of code coverage instrumentation. An agent configured to instrument source code and collect code coverage information is copied to the server at the IP address. During a training phase, the agent intercepts tests being run on source code and provides a dump of the interception results after each test is executed. Using such results, mappings of the tests to the source code is created and stored. During an execution phase, when new or modified source code file is being checked in, a testing application retrieves for execution tests which map to the source code file and to code dependent on the source code file.

## Claims

### Claim 1

A method for testing source code, comprising:
intercepting tests run on a first version of source code to determine the tests being run and code coverage from running the tests;
storing mappings of the determined tests to the first version of the source code and the determined code coverage in a database;
upon a second version of the source code being checked in, determining a set of tests to run on the second version of the source code and code that is dependent on the second version of the source code based on stored mappings and code coverage information in the database; and
running the determined set of tests on the second version of the source code and the dependent code.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
receiving a configuration file specifying an Internet Protocol (IP) address of a server running the tests on the first version of the source code and a type of code coverage instrumentation; and
copying an agent which interprets the type of code coverage instrumentation to the server based on the IP address, wherein the agent intercepts the tests run on the first version of the source code and determines the tests being run and the code coverage from running the tests.

### Claim 3 (depends on 1)

The method of claim 1, wherein the intercepting comprises running each of the tests and interpreting code coverage instrumentation.

### Claim 4 (depends on 1)

The method of claim 1, wherein a blacklist is used in determining the set of tests to run on the second version of the source code, the blacklist specifying a number of highest code coverage tests to run in cases of repeated code coverage.

### Claim 5 (depends on 1)

The method of claim 1, wherein a whitelist is used in determining the set of tests to run on the second version of the source code, the whitelist specifying a default set of tests to run.

### Claim 6 (depends on 1)

The method of claim 1, wherein the stored mappings of the tests to the source code are mappings of tests to source code files.

### Claim 7 (depends on 1)

The method of claim 1, wherein the stored mappings of the tests to the source code are mappings of tests to lines of the source code.

### Claim 8 (depends on 1)

The method of claim 1, wherein the second version of the source code includes a class and the dependent code includes one or more other classes which import the class in the second version of the source code.

### Claim 9 (depends on 1)

The method of claim 1, further comprising, learning one or more new tests or modified tests at a delta level.

### Claim 10

A non-transitory computer-readable storage medium containing a program which, when executed by one or more processors, performs operations for testing source code, the operations comprising:
intercepting tests run on a first version of source code to determine the tests being run and code coverage from running the tests;
storing mappings of the determined tests to the first version of the source code and the determined code coverage in a database;
upon a second version of the source code being checked in, determining a set of tests to run on the second version of the source code and code that is dependent on the second version of the source code based on stored mappings and code coverage information in the database; and
running the determined set of tests on the second version of the source code and the dependent code.

### Claim 11 (depends on 10)

The computer-readable storage medium of claim 10, the operations further comprising:
receiving a configuration file specifying an Internet Protocol (IP) address of a server running the tests on the first version of the source code and a type of code coverage instrumentation; and
copying an agent which interprets the type of code coverage instrumentation to the server based on the IP address, wherein the agent intercepts the tests run on the first version of the source code and determines the tests being run and the code coverage from running the tests.

### Claim 12 (depends on 10)

The computer-readable storage medium of claim 10, wherein the intercepting comprises running each of the tests and interpreting code coverage instrumentation.

### Claim 13 (depends on 10)

The computer-readable storage medium of claim 10, wherein a blacklist is used in determining the set of tests to run on the second version of the source code, the blacklist specifying a number of highest code coverage tests to run in cases of repeated code coverage.

### Claim 14 (depends on 10)

The computer-readable storage medium of claim 10, wherein a whitelist is used in determining the set of tests to run on the second version of the source code, the whitelist specifying a default set of tests to run.

### Claim 15 (depends on 10)

The computer-readable storage medium of claim 10, wherein the stored mappings of the tests to the source code are mappings of tests to source code files.

### Claim 16 (depends on 10)

The computer-readable storage medium of claim 10, wherein the stored mappings of the tests to the source code are mappings of tests to lines of the source code.

### Claim 17 (depends on 11)

The computer-readable storage medium of claim 11, wherein the second version of the source code includes a class and the dependent code includes one or more other classes which import the class in the second version of the source code.

### Claim 18 (depends on 11)

The computer-readable storage medium of claim 11, the operations further comprising, learning one or more new tests or modified tests at a delta level.

### Claim 19

A system, comprising:
a processor; and
a memory, wherein the memory includes a program configured to perform operations for testing source code, the operations comprising:
intercepting tests run on a first version of source code to determine the tests being run and code coverage from running the tests,
storing mappings of the determined tests to the first version of the source code and the determined code coverage in a database,
upon a second version of the source code being checked in, determining a set of tests to run on the second version of the source code and code that is dependent on the second version of the source code based on stored mappings and code coverage information in the database, and
running the determined set of tests on the second version of the source code and the dependent code.

### Claim 20 (depends on 19)

The system of claim 19, the operations further comprising:
receiving a configuration file specifying an Internet Protocol (IP) address of a server running the tests on the first version of the source code and a type of code coverage instrumentation; and
copying an agent which interprets the type of code coverage instrumentation to the server based on the IP address, wherein the agent intercepts the tests run on the first version of the source code and determines the tests being run and the code coverage from running the tests.
