The present disclosure relates to an approach that time needed to test software code after changes have been made to the software.
Software engineering best practice is that software should be thoroughly tested prior to release. Automating software testing is often the most cost effective approach and can involve thousands of test cases where a test case consists of a combination of test code, test data and test configuration required to execute the test. Typically, each test case tests some aspect of the software under test. When the code changes, identifying the corresponding subset of test cases to re-execute is a difficult task. For instance, if a comment has changed, or a rare error condition has been addressed, then the test may not need to be re-executed. If there are many tests in a single file, and only one test has changed, automatically selecting that test to re-execute is difficult. Existing solutions to selecting a subset of test cases include: manually selecting test cases, running all test cases, and using a makefile. Manually selecting the subset of test cases requires the tester to manually identify the test cases that test the specific software under test and is time consuming for the tester, and prone to human error. While re-executing all the test cases guarantees the subset of test cases that have changed are re-executed, this approach used vast time and/or resources which may result in the approach being infeasible. In addition, feedback to the development team is delayed due to the time required. Finally, using a makefile with the correct dependency listing lists the test cases that have changed. However, with the makefile approach, changes to the test case code that does not affect the test case run will be marked for rerun with similar challenges found in the approach of re-executing all of the tests.
An approach is provided to identify test cases based on changed test code. In the approach, test cases are compared to a current test environment that includes an instrumented software program that results in matching test cases. Matching test cases are selected based on a detection of one or more substantive changes to the current test environment. The current test environment is tested using the selected test cases. In an alternate approach, the current environment is tested with multiple test cases and code coverage metrics are retained. After the initial testing, modification of the software program results in comparing of the modification to the retained code coverage metrics whereupon a set of the test cases are selected and used to re-test the software program.
The foregoing is a summary and thus contains, by necessity, simplifications, generalizations, and omissions of detail; consequently, those skilled in the art will appreciate that the summary is illustrative only and is not intended to be in any way limiting. Other aspects, inventive features, and advantages of the present invention, as defined solely by the claims, will become apparent in the non-limiting detailed description set forth below.
The present invention may be better understood, and its numerous objects, features, and advantages made apparent to those skilled in the art by referencing the accompanying drawings, wherein:
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or computer program product. Accordingly, aspects of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to herein as a “circuit,” “module” or “system.” Furthermore, aspects of the present invention may take the form of a computer program product embodied in one or more computer readable medium(s) having computer readable program code embodied thereon.
Any combination of one or more computer readable medium(s) may be utilized. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer, server, or cluster of servers. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
Aspects of the present invention are described below with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
Northbridge 115 and Southbridge 135 connect to each other using bus 119. In one embodiment, the bus is a Direct Media Interface (DMI) bus that transfers data at high speeds in each direction between Northbridge 115 and Southbridge 135. In another embodiment, a Peripheral Component Interconnect (PCI) bus connects the Northbridge and the Southbridge. Southbridge 135, also known as the I/O Controller Hub (ICH) is a chip that generally implements capabilities that operate at slower speeds than the capabilities provided by the Northbridge. Southbridge 135 typically provides various busses used to connect various components. These busses include, for example, PCI and PCI Express busses, an ISA bus, a System Management Bus (SMBus or SMB), and/or a Low Pin Count (LPC) bus. The LPC bus often connects low-bandwidth devices, such as boot ROM 196 and “legacy” I/O devices (using a “super I/O” chip). The “legacy” I/O devices (198) can include, for example, serial and parallel ports, keyboard, mouse, and/or a floppy disk controller. The LPC bus also connects Southbridge 135 to Trusted Platform Module (TPM) 195. Other components often included in Southbridge 135 include a Direct Memory Access (DMA) controller, a Programmable Interrupt Controller (PIC), and a storage device controller, which connects Southbridge 135 to nonvolatile storage device 185, such as a hard disk drive, using bus 184. ExpressCard 155 is a slot that connects hot-pluggable devices to the information handling system. ExpressCard 155 supports both PCI Express and USB connectivity as it connects to Southbridge 135 using both the Universal Serial Bus (USB) the PCI Express bus. Southbridge 135 includes USB Controller 140 that provides USB connectivity to devices that connect to the USB. These devices include webcam (camera) 150, infrared (IR) receiver 148, keyboard and trackpad 144, and Bluetooth device 146, which provides for wireless personal area networks (PANs). USB Controller 140 also provides USB connectivity to other miscellaneous USB connected devices 142, such as a mouse, removable nonvolatile storage device 145, modems, network cards, ISDN connectors, fax, printers, USB hubs, and many other types of USB connected devices. While removable nonvolatile storage device 145 is shown as a USB-connected device, removable nonvolatile storage device 145 could be connected using a different interface, such as a Firewire interface, etcetera.
Wireless Local Area Network (LAN) device 175 connects to Southbridge 135 via the PCI or PCI Express bus 172. LAN device 175 typically implements one of the IEEE 0.802.11 standards of over-the-air modulation techniques that all use the same protocol to wireless communicate between information handling system 100 and another computer system or device. Optical storage device 190 connects to Southbridge 135 using Serial ATA (SATA) bus 188. Serial ATA adapters and devices communicate over a high-speed serial link. The Serial ATA bus also connects Southbridge 135 to other forms of storage devices, such as hard disk drives. Audio circuitry 160, such as a sound card, connects to Southbridge 135 via bus 158. Audio circuitry 160 also provides functionality such as audio line-in and optical digital audio in port 162, optical digital output and headphone jack 164, internal speakers 166, and internal microphone 168. Ethernet controller 170 connects to Southbridge 135 using a bus, such as the PCI or PCI Express bus. Ethernet controller 170 connects information handling system 100 to a computer network, such as a Local Area Network (LAN), the Internet, and other public and private computer networks.
While
The Trusted Platform Module (TPM 195) shown in
When code in the software program is modified by a tester, the corresponding test cases are identified and marked for execution. If the modified code only affects particular environments, then only the test cases associated with that environment are executed. Even though a test case may rely upon a certain modified component, it may not need to be re-executed if the modified test code path in that modified component does not affect the test case. The steps used to obtain information about the test code path that was followed in each of the test execution include (a) enabling the environment for code coverage of the software program, (b) running the test cases in the enabled environment, (c) retrieving the code coverage from the instrumented software code, (d) mapping the code coverage to the environment, and (e) storing information about the test case and the code coverage in a set of code coverage metrics. As indicated above, the software code is instrumented so that when it is executed, data pertaining to the test code path that was followed is retrieved. When running the test case, information about the environment that the test was run on is retrieved as well as other environmental information that the test case will rely upon. Environmental information may also include any inputs that the test case may need. The test code path that was followed during a test execution is obtained after a successful test run of the instrumented software code. The test case execution is mapped to a environment. The environment can include information such as the operating system version, the number of machines used, the data that is inputted into the test case, etc. The information about the test run and the test code covered is stored.
When code is modified the following steps are performed. The test code change has been checked into source control and is, at this point, detected as a modification. The test infrastructure detects the modification in the source code. After the source code change has been detected, the test infrastructure retrieves the lines, methods, and test cases that have changed. The source code change data is compared with the code coverage and with the environments on which the software program was executed. The changes in the source test code are checked with the test code coverage data to determine if there is an intersection and, if an intersection is found, to discover which test cases were affected. Because the test code coverage data is mapped to the environment, the process also determines which environments the tests should be executed. Once the process identifies the test cases that need to be executed, the identified test cases are marked to be run along with the environments on which the tests should be run.
When a new environment is added, the test infrastructure automatically detects the new environment and schedules a test run with test code coverage enabled. A new test environment can be based on a new operating system version, new input data, new software installed, etc. When a new environment is added for a test case or test cases, the test infrastructure detects the change and initiates a re-execution of the test coverage data. The test cases that are affected by the new environment will need to be run with the test code coverage environment enabled. Further details regarding the approach outlined above is set forth in
Testing process, described in more detail in the flowcharts shown in
At predefined process 415, the first test case used to test the software program is selected (see
At step 440, software program 350 is executed and tested in the current test environment using the selected test case which is retrieved from test case data store 320. At step 455, the testing process receives test results from the instrumented software program and these results are stored in test case results data store 360 for further evaluation and analysis by testers and software developers to ascertain whether software program 350 is operating correctly. At step 470, the process updates code coverage metrics in data store 330 to indicate that the tested test cases were previously tested. The storing includes storing the test code path and environment data, such as the operating system type and version used, the machines used, and the data inputted to the software program. At step 475, the code coverage data captured in step 470 is mapped to the current test environment and this mapping information is also stored in code coverage metrics data store 330.
A decision is made as to whether there are additional test cases that should be evaluated for possible selection (decision 480). If there are more test cases to be evaluated, then decision 480 branches to the “yes” branch which loops back to predefined process which evaluates the test cases and determines whether to select a test case for use in testing software program 350. This looping continues until there are no more test cases to evaluate, at which point decision 480 branches to the “no” branch. A decision is made as to whether there are additional environments that the tester wishes to establish and use in testing the software (decision 490). For example, if the software program is used on several different operating system versions, then after establishing a current test environment based on the a first operating system version, a subsequent current test environment can be established based on a second operating system version and the software can be retested by selecting test cases, as outlined above, for use in testing the software program running on the second operating system. If more environments need to be established and used to test the software program, then decision 490 branches to the “yes” branch which loops back to step 405 to establish the next test environment and evaluate the test cases to identify those test cases that should be used to test the software program given the newly established test environment. This looping continues until all of the desired testing environments have been established and used to test the software program, at which point decision 490 branches to the “no” branch and test processing ends at 495.
A decision is made (decision 530) as to whether the selected test case matches the current test environment (e.g., operating system version being used, code path being tested, possible data input constraints, etc.). If the selected test case does not match the current test environment, then decision 530 branches to the “no” branch which loops back to select and compare the next test case with the current test environment. This looping continues until either there are no more test cases to evaluate (at which point decision 520 branches to the “yes” branch whereupon at 595 processing returns to the calling routine without selecting a test case), or until a selected test case matches the current test environment, at which point decision 530 branches to the “yes” branch to further evaluate the selected test case.
At step 540, changes to the test case and the software program are identified. A decision is made as to whether substantive changes (e.g., non-comment changes, etc.) were identified to either the software program or to the test case (decision 550). If only non-substantive (e.g., comments, etc.) changes were identified, then decision 550 branches to the “no” branch which loops back to continue selecting and evaluating other test cases. On the other hand, if substantive changes were identified, then decision 550 branches to the “yes” branch for further processing.
A decision is made as to whether the test case is a new test case that has not yet been used to test the software program (decision 560). If the test case is a new test case, then decision 560 branches to the “yes” branch whereupon processing returns the selected test case to the calling routine (see
The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
While particular embodiments of the present invention have been shown and described, it will be obvious to those skilled in the art that, based upon the teachings herein, that changes and modifications may be made without departing from this invention and its broader aspects. Therefore, the appended claims are to encompass within their scope all such changes and modifications as are within the true spirit and scope of this invention. Furthermore, it is to be understood that the invention is solely defined by the appended claims. It will be understood by those with skill in the art that if a specific number of an introduced claim element is intended, such intent will be explicitly recited in the claim, and in the absence of such recitation no such limitation is present. For non-limiting example, as an aid to understanding, the following appended claims contain usage of the introductory phrases “at least one” and “one or more” to introduce claim elements. However, the use of such phrases should not be construed to imply that the introduction of a claim element by the indefinite articles “a” or “an” limits any particular claim containing such introduced claim element to inventions containing only one such element, even when the same claim includes the introductory phrases “one or more” or “at least one” and indefinite articles such as “a” or “an”; the same holds true for the use in the claims of definite articles.