主权项 |
1. 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; anda 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; andin 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. |