Streamlining Unit Testing Through Hot Code Swapping
First Claim
1. A method of testing a function using a mock function and test case definition, the method comprising:
- receiving a test case definition for a target function to be tested, the test case definition including an expected number of arguments and expected argument values to be sent in a call from the target function to an external function;
automatically creating, using a processor operatively coupled to a memory, a mock function using the test case definition;
replacing the external function called in the target function with the mock function;
calling the target function, the target function calling the mock function;
determining whether the target function called the mock function with the expected number of arguments and expected argument values; and
sending a failure or success report based on the determination.
1 Assignment
0 Petitions
Accused Products
Abstract
Methods and systems are described for testing methods and other functions by swapping external functions for mock functions. A test case definition is entered by a programmer, which can specify the expected number of arguments and argument values of external function or method calls, the context state, the return value, and any expected error conditions. The test case definition is used by a function tester to automatically create mock functions, modify the target function so that it calls the mock functions, execute the target function with specified arguments and a test context, and then compare the results to expected results.
-
Citations
20 Claims
-
1. A method of testing a function using a mock function and test case definition, the method comprising:
-
receiving a test case definition for a target function to be tested, the test case definition including an expected number of arguments and expected argument values to be sent in a call from the target function to an external function; automatically creating, using a processor operatively coupled to a memory, a mock function using the test case definition; replacing the external function called in the target function with the mock function; calling the target function, the target function calling the mock function; determining whether the target function called the mock function with the expected number of arguments and expected argument values; and sending a failure or success report based on the determination. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
-
-
19. A machine-readable storable medium embodying information indicative of instructions for causing one or more machines to perform operations comprising:
-
receiving a test case definition for a target function to be tested, the test case definition including an expected number of arguments and expected argument values to be sent in a call from the target function to an external function; automatically creating a mock function using the test case definition; replacing the external function called in the target function with the mock function; calling the target function, the target function calling the mock function; determining whether the target function called the mock function with the expected number of arguments and expected argument values; and sending a failure or success report based on the determination.
-
-
20. A computer system comprising:
-
at least one processor; a memory operatively coupled to the at least one processor, the processor enabled to execute program code including; program code for receiving a test case definition for a target function to be tested, the test case definition including an expected number of arguments and expected argument values to be sent in a call from the target function to an external function; program code for automatically creating a mock function using the test case definition; program code for replacing the external function called in the target function with the mock function; program code for calling the target function, the target function calling the mock function; program code for determining whether the target function called the mock function with the expected number of arguments and expected argument values; and program code for sending a failure or success report based on the determination.
-
Specification