Predicting code coverage without execution
AssigneeMicrosoft Technology Licensing, LLC
InventorsSHUBHAM CHANDEL, COLIN BRUCE CLEMENT, NEELAKANTAN SUNDARESAN, MICHELE TUFANO
Life of this patent
Estimating the term…
Abstract
A code coverage prediction system utilizes a neural transformer model with attention to generate a sequence of coverage symbols given a focal method and a test case. The sequence of coverage symbols indicates whether a line of source code is covered by the test case, missed by the test case or unreachable. The sequence of coverage symbols is aligned with the focal method to produce a coverage-annotated focal method that associates a predicted coverage symbol with each line of source code in the focal method.
Claims20
A system comprising:
- one or more processors;
- and
- a memory that stores one or more programs that are configured to be executed by the one or more processors, the one or more programs include instructions to perform actions that:
- obtain a focal method and a corresponding test case;
- create a prompt including the focal method and the corresponding test case;
- generate, from a first deep machine learning model given the prompt, a sequence of code coverage symbols, wherein a code coverage symbol of the sequence of code coverage symbols indicates coverage of the test case for a respective line of source code of the focal method;
- align the sequence of coverage symbols with the focal method to produce an annotated-coverage focal method;
- and
- output the annotated-coverage focal method.
A computer-implemented method, comprising:
- obtaining a focal method and a corresponding test case;
- predicting, from a first deep machine learning model given a line of source code of the focal method and the corresponding test case, one of a plurality of code coverage classes for the line of source code, wherein the plurality of code coverage classes includes a first class representing coverage of the line of source code by the test case and a second class representing non-coverage of the line of source code by the test case;
- associating a code coverage symbol with each code coverage class;
- marking the line of source code with a code coverage symbol associated with the predicted code coverage class of the line of source code;
- and
- outputting the focal method with the code coverage symbol.
A computer-implemented method, comprising:
- accessing a deep machine learning model trained to predict coverage of a test case for a first focal method of a source code program;
- creating a prompt for the deep machine learning model, wherein the prompt comprises the first focal method and the test case;
- obtaining a sequence of code coverage symbols from the deep machine learning model given the prompt, wherein a code coverage symbol of the sequence of code coverage symbols is associated with a respective line of source code of the first focal method, wherein the code coverage symbol represents coverage of the test case for the respective line of source code or no coverage of the test case for the respective line of source code;
- aligning the sequence of code coverage symbols with lines of source code of the first focal method;
- producing an annotated-coverage focal method from alignment of the sequence of code coverage symbols with the lines of source code of the first focal method;
- and
- outputting the annotated-coverage focal method.
Dependencies are inferred from the claim text.