The invention relates to software testing and in particular to providing a standardized test framework in which to test software.
Over the years, software systems have become more and more complex. Software, once typically developed by a single individual or a few individuals, now often requires a group of people with a variety of complementary skills working together towards a common goal. Large projects typically require the coordinated effort of many teams of developers. As the size and complexity of software increases, so too increases the task of software testing.
Software testing can be described as a process of running a program or set of programs in such a manner as to uncover any errors. One method of testing software is to develop test and run cases designed to uncover as many errors as possible. A test case describes an input, action, or event and an expected response, to determine if a feature of an application is working correctly. Test cases should be designed to “exercise” or “stress” the program by using and producing inputs and outputs. It would be helpful if there were a standardized, easily-understood way to develop and use test cases that addresses some of the old and new challenges in software testing.
A system, method and computer-readable medium containing computer-executable instructions provides a framework for writing and executing test cases. The testing system may include a driver, dispatcher and one or more executors. One test case or a group of test cases may be provided to the testing system. Each test case includes one or more actions and may be in the form of an XML document. Each action may be dependent on or independent of previous or following actions. In preparation for executing the test case one or more times, system initialization is performed. One or more iterations of the test case may be executed and housekeeping tasks may be performed in preparation for executing the next test case. Executing an iteration of a test case includes initialization in preparation for executing the iteration, performing the actions that test the software and validating the results (including comparing the actual result with an expected result and making entries to a log) and performing local cleanup (i.e., cleanup relevant to the iteration).
The foregoing summary, as well as the following detailed description of illustrative embodiments, is better understood when read in conjunction with the appended drawings. For the purpose of illustrating the invention, there is shown in the drawings exemplary constructions of the invention; however, the invention is not limited to the specific methods and instrumentalities disclosed. In the drawings:
a-c is an exemplary test case schema in accordance with one embodiment of the invention.
Overview
One test case or a group of test cases are input to a system including a driver, dispatcher and one or more executors. The driver may interface with a test case management system. The dispatcher drives actions specified in the test case through one or more executors. The one or more executors perform the action(s) specified in the test case or test group. A logger may log events such as trace statements, errors, warnings or other information of interest to a log file.
A test case may include an action or a series of actions to be performed and may identify an executor to perform the action. A test case may be provided as an XML file. A single test case or group of test cases may be provided for execution. A group of test cases may include one or more test cases and one or more groups of test cases.
When testing software, initialization in preparation for running the test case may be performed, the test case executed one or more times, and housekeeping tasks in preparation for running the next test case performed. Running an iteration of the test case comprises initialization in preparation for running the iteration of the test case, performing one iteration of the actions that test the software, and validating the results (e.g., comparing actual and expected results) and performing local cleanup (i.e., cleanup relevant to the iteration of the test case that has been run).
A method for preparing a test case includes identifying one or more actions required to test a feature. Each action within the test case may identify an executor to carry out the specified actions. Each test case may include one or more actions which are dependent on or independent of previous or following actions. A test case may also include a header that identifies files or databases to be acted on, and the like. The header may include meta-data pertaining to the test. For example, the header may include the owner of the test case, the title of the test case, a description of the test case, the priority for the test, the specific product feature or sub-feature that is to be tested and other data intended to describe the test. The test case may be presented as an XML document. After a test case has been developed, the test case may be copied and modified to create a new test case. Test cases may be combined into test groups. Test groups may include test cases, test groups or a mixture of test cases and test groups. Specified elements of a test file or test group may be tested sequentially or concurrently.
Exemplary Computing Environment
Although not required, the invention can be implemented via an application programming interface (API), for use by a developer, and/or included within the network browsing software which will be described in the general context of computer-executable instructions, such as program modules, being executed by one or more computers, such as client workstations, servers, or other devices. Generally, program modules include routines, programs, objects, components, data structures and the like that perform particular tasks or implement particular abstract data types. Typically, the functionality of the program modules may be combined or distributed as desired in various embodiments. Moreover, those skilled in the art will appreciate that the invention may be practiced with other computer system configurations. Other well known computing systems, environments, and/or configurations that may be suitable for use with the invention include, but are not limited to, personal computers (PCs), automated teller machines, server computers, hand-held or laptop devices, multi-processor systems, microprocessor-based systems, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and the like. The invention may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network or other data transmission medium. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
With reference to
Computer 110 typically includes a variety of computer readable media. Computer readable media can be any available media that can be accessed by computer 110 and includes both volatile and nonvolatile media, removable and non-removable media. By way of example, and not limitation, computer readable media may comprise computer storage media and communication media. Computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CDROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by computer 110. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared, and other wireless media. Combinations of any of the above should also be included within the scope of computer readable media.
The system memory 130 includes computer storage media in the form of volatile and/or nonvolatile memory such as read only memory (ROM) 131 and random access memory (RAM) 132. A basic input/output system 133 (BIOS), containing the basic routines that help to transfer information between elements within computer 110, such as during start-up, is typically stored in ROM 131. RAM 132 typically contains data and/or program modules that are immediately accessible to and/or presently being operated on by processing unit 120. By way of example, and not limitation,
The computer 110 may also include other removable/non-removable, volatile/nonvolatile computer storage media. By way of example only,
The drives and their associated computer storage media discussed above and illustrated in
A monitor 191 or other type of display device is also connected to the system bus 121 via an interface, such as a video interface 190. A graphics interface 182, such as Northbridge, may also be connected to the system bus 121. Northbridge is a chipset that communicates with the CPU, or host processing unit 120, and assumes responsibility for accelerated graphics port (AGP) communications. One or more graphics processing units (GPUs) 184 may communicate with graphics interface 182. In this regard, GPUs 184 generally include on-chip memory storage, such as register storage and GPUs 184 communicate with a video memory 186. GPUs 184, however, are but one example of a coprocessor and thus a variety of coprocessing devices may be included in computer 110. A monitor 191 or other type of display device is also connected to the system bus 121 via an interface, such as a video interface 190, which may in turn communicate with video memory 186. In addition to monitor 191, computers may also include other peripheral output devices such as speakers 197 and printer 196, which may be connected through an output peripheral interface 195.
The computer 110 may operate in a networked environment using logical connections to one or more remote computers, such as a remote computer 180. The remote computer 180 may be a personal computer, a server, a router, a network PC, a peer device or other common network node, and typically includes many or all of the elements described above relative to the computer 110, although only a memory storage device 181 has been illustrated in
When used in a LAN networking environment, the computer 110 is connected to the LAN 171 through a network interface or adapter 170. When used in a WAN networking environment, the computer 110 typically includes a modem 172 or other means for establishing communications over the WAN 173, such as the Internet. The modem 172, which may be internal or external, may be connected to the system bus 121 via the user input interface 160, or other appropriate mechanism. In a networked environment, program modules depicted relative to the computer 110, or portions thereof, may be stored in the remote memory storage device. By way of example, and not limitation,
One of ordinary skill in the art can appreciate that a computer 110 or other client device can be deployed as part of a computer network. In this regard, the present invention pertains to any computer system having any number of memory or storage units, and any number of applications and processes occurring across any number of storage units or volumes. The present invention may apply to an environment with server computers and client computers deployed in a network environment, having remote or local storage. The present invention may also apply to a standalone computing device, having programming language functionality, interpretation and execution capabilities.
System and Method for Providing a Test Framework
In one embodiment of the invention, software tester 220 is comprised of a driver 204, a dispatcher 206 and one or more executors 208a, 208b, 208c, etc. Driver 204 receives the input to the test framework. In one embodiment of the invention, driver 204 is a command line utility that is used to start up the software tester. For example, driver 204 may represent a command line utility to which is provided the path of a test case or a test group file. Driver 204 may also be provided with instructions concerning the execution of the test. Driver 204 may also provide a number of command line options to be used to control the execution of the provided input. Driver 204 may be a pluggable layer so that, for example, a user interface driver may be used instead of the command line driver described above. It will be understood that although a command line driver and a user interface driver have been described, the use of any kind of driver, is contemplated. Such a driver may be written to interface with any Test Case Management system (TCM), to read test cases from a database and exercise those tests. Some TCM systems, for example, may need to communicate with a driver that supports command line execution in which case driver 204 must support command line execution. Another TCM system may implement a callable interface (such as COM, NET, JAVA or the like), in which case driver 204 must be able to communicate with the called interface. Driver 204 may be written to support specific performance and stress testing requirements. For example, driver 204 may be developed to exercise all the test cases at one time, or to exercise the tests continuously for some period of time. Any of the above listed drivers or other suitable drivers are included within the scope of the invention. Driver 204 may interface with one or more test case management systems 214.
Dispatcher 206 reads the content of the input test file 212 and schedules an execution time for each action specified in the input test file 212. In one embodiment of the invention, execution times for the actions in the input test file 212 are scheduled sequentially, although any specified execution sequence is contemplated. In one embodiment, dispatcher 206 determines from the input test file 212 which executor 208a, 208b, etc. is capable of performing the commands in the action and directs the appropriate executor to execute the actions. For example, dispatcher 206 may read the name of the action from an input test case and from the name determine which executor in library 222 (described below) can perform that action. Dispatcher 206 may call the appropriate executor, pass the action to it and direct the executor to perform the action. Dispatcher 206 may then move on to the next action. In one embodiment of the invention, the default is to schedule action sequentially. There may be an option, specifiable in the test case XML or in the test group XML that indicates that the actions are to be performed in parallel instead of sequentially. In one embodiment of the invention certain actions can be specified to be performed in sequence while another set of actions are performed in parallel.
Tester 220 also includes one or more executors 208a, 208b, 208c, etc. Each executor may be a component or routine capable of executing a set of actions. Typically, an executor executes a set of related actions, although the invention is not so limited. For example an executor may be a component capable of compiling files of programs written in a new programming language. Similarly an executor may be a component capable of creating or updating database tables. In one embodiment of the invention, tester 220 includes a library of executors 222, the library comprising a number of executors 208a, 208b, etc.
Tester 220 may also include a logger 210. Logger 210 in one embodiment of the invention performs logging functions and records certain events that occur during execution. Log entries are typically used in debugging to determine where things went wrong. Logger 210 may record errors, warnings, trace statements and any other suitable events in a log 218. In one embodiment of the invention, the level of logging to be performed can be specified. For example, the level of logging may be specifiable via an option in the driver 204. In one embodiment of the invention if a level of logging is not selected, a default level of logging is performed, (e.g., warnings and errors are logged). In one embodiment of the invention, the log location is also specifiable, for example, log statements may be written to a file, a database, sent to an error control process, or to a window debugging function. In one embodiment of the invention, should log location not be specified a default log location (e.g., log statements written to a file) is selected.
In one embodiment of the invention, an exception based model is followed. In an exception based model, no flags are raised if no abnormal results are encountered. If an abnormal result is detected, whether in the driver, dispatcher or executor, an exception is logged, capturing relevant information associated with the exception. If the exception raised is a critical failure, the exception is bubbled back up to the driver, the driver declares a failure of the test case and the test case ends. When a non-critical exception is raised, information is logged and execution continues.
As an example of a noncritical exception, if in the testing of the compilation of a program in a new programming language, an unexpected compilation error is detected, the error may be logged or entered into a log file and the test case may be allowed to continue.
As an example of a critical exception, if in the testing of the compilation of a program in a new programming language, in first time initialize, the action specified is to compile a program XYZ located at path P, but program XYZ is not found at path P, a critical exception may be raised, information such as but not limited to “file XYZ not found at path P” may be logged in the log file and execution of the test case may terminate.
In
Each of the elements 504, 506, 508, 510 and 512 may include one or more actions to be performed for the test case. “First time initialize” 504 represents a set of initialization actions that need to be performed in preparation for one or more executions of the test case. The middle 3 elements, “before each run initialize” 506, “run one iteration” 508, and “after each iteration” 510 represent the core of the test case and may be repeated or iterated a number of times. The fifth element, “final cleanup” 512 represents a set of actions that need to be done after the final iteration of the test case, to leave whatever system is being tested in condition for subsequent tests.
The middle 3 elements: “before each run initialize” 506, “run one iteration” 508, “after each iteration” 510 can be run zero or more times within a test case. “Before each run initialize” 506 may represent further initialization that needs to be done before an iteration of the test case is run. “Run one iteration” 508 represents one or more actions to be taken to execute one iteration of the test. “After each iteration” 510 represents actions to perform validation of results, (e.g., compare actual and expected results) and local cleanup after one iteration of the test. In one embodiment of the invention, “before each run initialize” 506, “run one iteration” 508, and “after each iteration” 510 can be performed repeatedly. Hence, for example, a particular execution of a test case could run “first time initialize” once, then the middle three elements several times, (i.e., N times) in a loop and “final cleanup” once. In one embodiment of the invention, the number of times, N, that the core is run is specified via a parameter submitted to the driver.
Child 604 includes one action to be performed, “CMDLINE” 618. The “CMDLINE” action 618 includes information associated with the action, in this case, the name of the executable, “cmd.exe” 620 and the arguments that cmd.exe takes, “/c notepad.exe” 622.
A group of test cases may be input to the tester. A test group may include individual test cases, test groups or a combination thereof. For example, XML file 700 of
Suppose, for example, a new programming language including a compiler and an engine for executing programs written in the new language is to be tested. In this situation, an appropriate test case may include a “first time initialize” action that would compile a specified program written in the new language, thus testing the compiler for the new programming language. The “first time initialize” element may place the compiled program in a location accessible to the execution engine so that the execution engine could execute the program in a later step. The middle three elements may test the execution engine by executing the compiled program a number of times. In each iteration, in “before each run initialize” the log may be cleared. In “run one iteration”, the compiled program may be executed once in each iteration. In “after each iteration”, validation of the results of the single execution may be performed for each iteration. Perhaps the compiled program would be executed three times, each time clearing the log in “before each run initialize” and validating the results of the execution in “after each iteration”.
As another example, suppose only the compiler is to be tested. In this situation, an environment to generate code may be set up in “first time initialize”. “Before each run initialize” may include an action to generate a particular program, “run one iteration” may include an action to compile the program and “after each iteration” may include an action to verify that the program was successfully compiled. It will be apparent that the test files can be geared to the particular focus of testing desired.
If a database application is to be tested in which 3 iterations are to be run, in “first time initialize”, tables may be created, in “before each run initialize” tables may be populated, in “run one iteration” operations on these tables may be performed and in “after each iteration”, results of this execution may be validated, (i.e., if in the test, four new records were to be added, the database would be checked to determine that the four new records are now in the database). In “after each iteration”, the tables may be cleared in preparation for the second iteration in which the tables would again be populated, the addition operation performed, the results validated and the tables cleared and so on. In “final cleanup” the tables may be discarded.
Suppose now Test Group 700 is to be executed. Upon execution of Test Group 700, Test Case 1 at the location specified by path “a” is executed, as described above with respect to
A test group may include individual test cases, test groups or a combination thereof. For example, XML file 700 of
Test group “Notepad IDW” 804 includes a name “Notepad IDW” 814, a group setup 816 (“Win2K\Tools\AddNotePadToShrtcut.xml”) for the test group 804 and a group cleanup 818 for the test group 804. Test group “Notepad IDW” 804 also includes the test case file name on which the test is to be run: “OpenNotepad.xml” and its location or path: “Sin2K\Tools\OpenNotepad.xml” 820.
Test case “Open Notepad #2” 806 includes a name “Open Notepad #2” 822, a description “open Notepad UI #2” 824, and so on as described above for the test case of
When developing Test Cases and Test Groups, Test Groups may be developed as a collection of Test Cases that test a particular feature and Test Groups may be developed as a collection of Test Groups that collectively test some or all of the features of a software system or complete application. Hence different Test Groups may have a different testing focus and may require special setup and cleanup actions. Each Test Group may therefore include group setup or group cleanup actions which in one embodiment of the invention are added after “<Root” in root element 702 and after </Root” in element 712. For example, in the exemplary test group 800 of
Suppose for example, a set of stored procedures that populates a database is to be tested and a set of test cases to test these stored procedures is to be developed. In writing the XML for the first test case, in “before each run initialize”, perhaps an action to provide the sample data listed in the XML to the stored procedure would be listed. In “run one iteration” the action may be to execute the procedure using the sample data provided. In “after each iteration” an action to validate the outcome of the execution may be listed. The expected result may be listed in the “after each iteration” element so that the actual and expected results could be compared. In “final cleanup” an action to clear the database may be listed.
It will be apparent from the discussion above that using the test framework may simplify testing into a series of simple steps that can be used to test many diverse software systems. While the input and results may be different, the general template for the testing procedure is the same.
It is also apparent that the above described set of structures facilitates the development of test cases and test groups.
Test cases and test groups can be generated independently, (for example, by different teams in a software development project, enabling a project team to develop tests independently of other teams). Suppose for example that a certain product has several subfeatures, each subfeature associated with its own development and testing team. Each team could develop a group of test cases to test its own subfeature. To test the whole product, all the test groups for all of the teams could be combined into a single test group that references all the teams' test groups. It will be apparent that such a test group may include several levels of test groups (i.e., test groups could be nested).
The various techniques described herein may be implemented in connection with hardware or software or, where appropriate, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as floppy diskettes, CD-ROMs, hard drives, or any other machine-readable storage medium, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention. In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. One or more programs that may utilize the creation and/or implementation of domain-specific programming models aspects of the present invention, e.g., through the use of a data processing API or the like, are preferably implemented in a high level procedural or object oriented programming language to communicate with a computer system. However, the program(s) can be implemented in assembly or machine language, if desired. In any case, the language may be a compiled or interpreted language, and combined with hardware implementations.
While the present invention has been described in connection with the preferred embodiments of the various figures, it is to be understood that other similar embodiments may be used or modifications and additions may be made to the described embodiments for performing the same function of the present invention without deviating therefrom. Similarly it will be understood that although the test framework is described within the context of an automated way of testing software, the invention is not so limited and may be used wherever the scheduling of processes within a standardized format is useful, as for example in the context of business processes. Therefore, the present invention should not be limited to any single embodiment, but rather should be construed in breadth and scope in accordance with the appended claims.