Test double generation
AssigneeFujitsu Limited
InventorHiroaki Yoshida
Life of this patent
Estimating the term…
Abstract
A method to generate test double proxies for callee functions of a function under test may include generating an initial set of test double proxies with abstract test stubs for all callee functions called by the function under test. Each of the test double proxies in the initial set of test double proxies may correspond to a different one of the callee functions. The method may also include generating a first refined set of test double proxies that includes a first refined test stub instead of a first one of the abstract test stubs for a first test double proxy in the initial set of test double proxies in response to determining that refining the first one of the abstract test stubs improves a test coverage of the function under test.
Claims12
A method to generate test double proxies for callee functions of a function under test, the method comprising:
- generating an initial set of test double proxies with abstract test stubs for all callee functions called by a function under test, each of the test double proxies in the initial set of test double proxies corresponding to a different one of the callee functions;
- and
- generating a first refined set of test double proxies that includes a first refined test stub instead of a first one of the abstract test stubs for a first test double proxy in the initial set of test double proxies in response to determining that refining the first one of the abstract test stubs improves a test coverage of the function under test;
- wherein generating the initial set of test double proxies with the abstract test stubs for all the callee functions called by the function under test comprises, for each of the callee functions, generating:
- a test stub that does nothing if the corresponding one of the callee functions does not return a variable;
- and
- a parameterized test stub that returns a symbolic variable if a corresponding one of the callee functions returns a variable,
- wherein the method further comprises iteratively refining a current set of test double proxies prior to generating an immediately subsequent refined set of test double proxies, wherein the current set of test double proxies includes the initial set of test double proxies or a refined set of test double proxies that precedes the immediately subsequent refined set of test double proxies;
- and
- wherein iteratively refining the current set of test double proxies prior to generating the immediately subsequent refined set of test double proxies comprises:
- determining whether all subsets of the abstract test stubs have been refined in the current set of test double proxies;
- in response to determining that all subsets of the abstract test stubs in the current set of test double proxies have been refined, generating the immediately subsequent refined set of test double proxies;
- in response to determining that all subsets of the abstract test stubs in the current set of test double proxies have not been refined, temporarily refining a current subset of the abstract test stubs in the current set of test double proxies that has not been refined;
- symbolically executing the function under test using both a current subset of the current set of test double proxies with the temporarily refined current subset of the abstract test stubs and a current remainder of the current set of test double proxies;
- in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies timing out, or in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies both not timing out and not improving a previous test coverage of the function under test, unrefining the temporarily refined current subset of the abstract test stubs;
- and
- in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies both not timing out and improving the previous test coverage of the function under test, including the temporarily refined current subset of the abstract test stubs as a permanent refinement in the immediately subsequent refined set of test double proxies.
An apparatus comprising:
- a processor;
- and
- a non-transitory computer-readable medium communicatively coupled to the processor and having stored thereon computer instructions comprising:
- an abstraction module executable by the processor to generate an initial set of test double proxies with abstract test stubs for all callee functions called by a function under test, each of the test double proxies in the initial set of test double proxies corresponding to a different one of the callee functions;
- a refinement module executable by the processor to generate a first refined set of test double proxies that includes a first refined test stub instead of a first one of the abstract test stubs for a first test double proxy in the initial set of test double proxies in response to a determination that refining the first one of the abstract test stubs improves a test coverage of the function under test;
- a symbolic execution module;
- a test coverage module;
- and
- a user interface module executable by the processor to receive user input effective to refine a second one of the abstract test stubs in the first refined set of test double proxies to a user-specified test stub;
- wherein:
- the refinement module, the user interface module, the symbolic execution module, and/or the test coverage module are executable by the processor to iteratively refine a current set of test double proxies prior to generating an immediately subsequent refined set of test double proxies;
- the current set of test double proxies includes the initial set of test double proxies or a refined set of test double proxies that precedes the immediately subsequent refined set of test double proxies;
- and
- the refinement module, the user interface module, the symbolic execution module, and/or the test coverage module are executable by the processor to iteratively refine the current set of test double proxies as follows:
- the refinement module being further executable by the processor to determine, prior to the generation of the immediately subsequent refined set of test double proxies, whether all subsets of the abstract test stubs have been refined in the current set of test double proxies, wherein the refinement module is executable by the processor to generate the immediately subsequent refined set of test double proxies in response to determining that all subsets of the abstract test stubs have been refined in the current set of test double proxies;
- in response to determining that all subsets of the abstract test stubs in the current set of test double proxies have not been refined, the refinement module being further executable by the processor to temporarily refine a current subset of the abstract test stubs in the current set of test double proxies that has not been refined;
- the symbolic execution module being executable by the processor to symbolically execute, prior to the generation of the immediately subsequent refined set of test double proxies, the function under test using both a current subset of the current set of test double proxies with the temporarily refined current subset of the abstract test stubs and a current remainder of the current set of test double proxies;
- in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies timing out, or in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies both not timing out and not improving a previous test coverage of the function under test, the refinement module being further executable by the processor to unrefine, prior to the generation of the immediately subsequent refined set of test double proxies, the temporarily refined current subset of the abstract test stubs;
- and
- in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies both not timing out and improving the previous test coverage of the function under test, the refinement module being further executable by the processor to include the temporarily refined current subset of the abstract test stubs as a permanent refinement in the immediately subsequent refined set of test double proxies.
A non-transitory computer-readable medium having computer instructions stored thereon that are executable by a processor to perform operations comprising:
- generating an initial set of test double proxies with abstract test stubs for all callee functions called by a function under test, each of the test double proxies in the initial set of test double proxies corresponding to a different one of the callee functions;
- generating a first refined set of test double proxies that includes a first refined test stub instead of a first one of the abstract test stubs for a first test double proxy in the initial set of test double proxies in response to determining that refining the first one of the abstract test stubs improves a test coverage of the function under test;
- and
- receiving user input effective to refine a second one of the abstract test stubs in the first refined set of test double proxies to a user-specified test stub;
- wherein generating the initial set of test double proxies with the abstract test stubs for all the callee functions called by the function under test comprises, for each of the callee functions, generating:
- a test stub that does nothing if the corresponding one of the callee functions does not return a variable;
- and
- a parameterized test stub that returns a symbolic variable if a corresponding one of the callee functions returns a variable,
- wherein the operations further comprise iteratively refining a current set of test double proxies prior to generating an immediately subsequent refined set of test double proxies, wherein the current set of test double proxies includes the initial set of test double proxies or a refined set of test double proxies that precedes the immediately subsequent refined set of test double proxies;
- and
- wherein iteratively refining the current set of test double proxies prior to generating the immediately subsequent refined set of test double proxies comprises:
- determining whether all subsets of the abstract test stubs have been refined in the current set of test double proxies;
- in response to determining that all subsets of the abstract test stubs in the current set of test double proxies have been refined, generating the immediately subsequent refined set of test double proxies;
- in response to determining that all subsets of the abstract test stubs in the current set of test double proxies have not been refined, temporarily refining a current subset of the abstract test stubs in the current set of test double proxies that has not been refined;
- symbolically executing the function under test using both a current subset of the current set of test double proxies with the temporarily refined current subset of the abstract test stubs and a current remainder of the current set of test double proxies;
- in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies timing out, or in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies both not timing out and not improving a previous test coverage of the function under test, unrefining the temporarily refined current subset of the abstract test stubs;
- and
- in response to symbolic execution of the function under test using both the current subset of the current set of test double proxies and the remainder of the current set of test double proxies both not timing out and improving the previous test coverage of the function under test, including the temporarily refined current subset of the abstract test stubs as a permanent refinement in the immediately subsequent refined set of test double proxies.
Dependencies are inferred from the claim text.