|
|
|
Having interactive or visual |
Test execution framework for automated software testing6889158
Abstract
Methods, systems, and computer program products for testing software components without explicitly having to specify each test or test environment. A computer system for automated testing loads and parses and test file. The test file contains code sections that identify software components to test, locations sections that identify locations to run the software components, an expandable variation section that associates the software components with locations, and an expansion section that defines rules for expanding the expandable variation section. From the expandable variation section, the computer system creates expanded variation sections that associate particular software components with particular locations. Then, for each particular software component and locations, the computer system executes setup instructions to prepare for running the particular software component, executes the particular software component, and executes cleanup instructions. The test file may conform to one or more eXtensible Markup Language (XML) schemas.
Claims
1. In a computer system for automated software testing to determine whether or not software operates as intended, a method of applying one or more tests to one or more software components without having to specify each test or test environment explicitly, the method comprising acts of:
reading a test file containing (i) one or more code sections that identify one or more software components to test, (ii) one or more location sections that identify one or more locations to run the one or more software components, (iii) an expandable variation section that associates the one or more software components with the one or more locations, and (iv) an expansion section that defines rules for expanding the expandable variation section;
expanding the expandable variation section to create one or more expanded variation sections, each associating a particular one of the one or more software components with a particular one of the one or more locations; and
for each particular software component and location, calling a code setup routine to prepare for executing the particular software component, a code run routine to execute the particular software component for testing, and a code cleanup routine to reverse changes made by the code setup and run routines as needed.
2. A method as recited in claim 1, wherein the test file contains one or more group sections for grouping each of the one or more expanded variation sections, the method further comprising an act of, for each of the one or more group sections, calling a group setup routine prior to executing any expanded variation section within the corresponding group section, and calling a group cleanup routine after executing any expanded variation section within the corresponding group section.
3. A method as recited in claim 2, wherein the test file contains one or more set sections for logically grouping the one or more expanded variation sections.
4. A method as recited in claim 1, further comprising an act of calling an optional setup routine for a corresponding group section.
5. A method as recited in claim 1, further comprising an act of passing context information into a code section.
6. A method as recited in claim 1, wherein the expansion section identifies a list expansion algorithm which generates permutations from a list of one or more placeholders and list of one or more substitution strings.
7. A method as recited in claim 1, wherein the test file conforms to an eXtensible Markup Language (XML) schema.
8. In a computer system for automated software testing to determine whether or not software operates as intended, a computer program product comprising one or more computer readable media carrying computer executable instructions that implement a method of applying one or more tests to one or more software components without having to specify each test or test environment explicitly, the method comprising acts of:
reading a test file containing (i) one or more code sections that identify one or more software components to test, (ii) one or more location sections that identify one or more locations to run the one or more software components, (iii) an expandable variation section that associates the one or more software components with the one or more locations, and (iv) an expansion section that defines rules for expanding the expandable variation section;
expanding the expandable variation section to create one or more expanded variation sections, each associating a particular one of the one or more software components with a particular one of the one or more locations; and
for each particular software component and location, calling a code setup routine to prepare for executing the particular software component, a code run routine to execute the particular software component for testing, and a code cleanup routine to reverse changes made by the code setup and run routines as needed.
9. A computer program product as recited in claim 8, the method further comprising an act of calling an optional setup routine for a corresponding code section.
10. A computer program product as recited in claim 8, the method further comprising an act of passing synchronization information into a group section.
11. A computer program product as recited in claim 8, the method further comprising an act of writing testing information to a log.
12. A computer program product as recited in claim 8, wherein the expansion section identifies a pair-wise expansion algorithm that generates unique combinations from a list of substitution strings and a number of substitution strings to be included in each unique combination.
13. A computer program product as recited in claim 8, wherein the test file contains one or more parameter sections, the method further comprising an act of accessing data within at least one of the parameter sections from a group section within a scope that includes the at least one parameter section and the group section.
14. A computer program product as recited in claim 8, the method further comprising an act of writing one or more actual test results for use in determining either a pass or fail result for a code section.
15. A computer program product as recited in claim 14, wherein the test file contains one or more expected test results, and wherein the test file references one or more result comparators, the method further comprising an act of comparing the one or more actual test results with the one or more expected test results to determine the pass or fail result for the code section.
16. In a computer system for automated software testing to determine whether or not software operates as intended, a method of applying one or more tests to one or more software components without having to specify each test or test environment explicitly, the method comprising step for:
loading and parsing a test file containing (i) one or more code sections that identify one or more software components to test, (ii) one or more location sections that identify one or more locations to run the one or more software components, (iii) an expandable variation section that associates the one or more software components with the one or more locations, and (iv) an expansion section that defines rules for expanding the expandable variation section;
creating one or more expanded variation sections from the expandable variation section, each associating a particular one of the one or more software components with a particular one of the one or more locations; and
for each particular software component and location, executing setup instructions to prepare for running the particular software component, the particular software component being tested, and cleanup instructions following execution of the software component being tested.
17. A method as recited in claim 16, further comprising an act of calling an optional cleanup routine for a corresponding group section.
18. A method as recited in claim 16, further comprising a step for sharing context information between a group and a portion.
19. A method as recited in claim 16, wherein the expansion section identifies a data file expansion algorithm that replaces one or more placeholders with a comma separated list of substitutes from a data file.
20. A method as recited in claim 16, wherein the test file contains one or more parameter sections, the method further comprising an act of accessing data within at least one of the parameter sections from a code section within a scope that includes the at least one parameter section and the code section.
21. A method as recited in claim 16, further comprising a step for recording one or more actual test results for use in determining either a pass or fail result for a code section.
22. A method as recited in claim 21, wherein the test file contains one or more expected test results, and wherein the test file references one or more result comparators, the method further comprising a step for using the one or more result comparators to compare the one or more actual test results with the one or more expected test results to determine the pass or fail result for the code section.
23. A method as recited in claim 21, wherein the test file contains one or more expected test results, and wherein the test file references one or more result comparators for comparing one or more actual test results with the one or more expected test results to determine a pass or fail result for a code section.
24. In a computer system for automated software testing to determine whether or not software operates as intended, a computer program product comprising one or more computer readable media carrying computer executable instructions that implement a method of applying one or more tests to one or more software components without having to specify each test or test environment explicitly, the method comprising steps for:
loading and parsing a test file containing (i) one or more code sections that identify one or more software components to test, (ii) one or more location sections that identify one or more locations to run the one or more software components, (iii) an expandable variation section that associates the one or more software components with the one or more locations, and (iv) an expansion section that defines rules for expanding the expandable variation section;
creating one or more expanded variation sections from the expandable variation section, each associating a particular one of the one or more software components with a particular one of the one or more locations; and
for each particular software component and location, executing setup instructions to prepare for running the particular software component, the particular software component being tested, and cleanup instructions following execution of the software component being tested.
25. A computer program product as recited in claim 24, the method further comprising an act of calling an optional cleanup routine for a corresponding code section.
26. A computer program product as recited in claim 24, wherein the test file contains at least two code sections, the method further comprising a step for sharing synchronization information between the at least two code sections.
27. A computer program product as recited in claim 24, the method further comprising a step for recording testing information in a log.
28. A computer program product as recited in claim 27, wherein testing information is recorded in the log based on the selection of one or more logging levels comprising at least one of an always level, an error level, a warn level, and a trace level.
29. A computer program product as recited in claim 24, wherein the expansion section identifies a range expansion algorithm that substitutes all values within a range defined by a lower and upper limit for a placeholder.
30. For an automated software testing system used to determine whether or not software operates as intended, a computer program product comprising one or more computer readable media for applying one or more tests to one or more software components without explicitly having to specify each test or test environment, the computer program product carrying a test file that comprises:
one or more code sections that identify one or more software components to test;
one or more location sections that identify one or more locations to run the one or more software components;
at least one expandable variation section that associates the one or more software components with the one or more locations; and
an expansion section that defines rules for creating one or more expanded variation sections and associating a particular software component with a particular location.
31. A computer program product as recited in claim 30, wherein the test file further comprises one or more group sections for grouping each of the one or more expanded variation sections.
32. A computer program product as recited in claim 31, wherein the test file contains one or more parameter sections for access from a code or group section within a scope that includes the at least one parameter section and the code or group section.
33. A computer program product as recited in claim 30, wherein the test file further comprises one or more set sections for logically grouping the one or more expanded variation sections.
34. A computer program product as recited in claim 30, wherein the expansion section identifies an expansion algorithm comprising at least one of (i) a list expansion algorithm which generates permutations from a list of one or more placeholders and list of one or more substitution strings, (ii) a pair-wise expansion algorithm that generates unique combinations from a list of substitution strings and a number of substitution strings to be included in each unique combination, (iii) a data file expansion algorithm that replaces one or more placeholders with a comma separated list of substitutes from a data file, and (iv) a range expansion algorithm that substitutes all values within a range defined by a lower and upper limit for a placeholder.
35. A computer program product as recited in claim 30, wherein the test file conforms to an eXtensible Markup Language (XML) schema.
Description
CROSS-REFERENCE TO RELATED APPLICATIONS
N/A
BACKGROUND OF THE INVENTION
1. The Field of the Invention
The present invention relates to automated software testing. More particularly, the present invention relates to methods, systems, and computer program products for testing software components without explicitly having to specify each test or test environment.
2. Background and Related Art
Testing is an integral part of the software development process. As applications are written, developers often run their code to test the particular features being added or enhanced to assure that the developer's code operates as intended. While testing, developers frequently uncover programming errors, either in the form of erroneous design (what the developer thought would work does not) or erroneous implementation (correctly designed, but improperly coded).
The testing performed by a developer, however, tends to be limited in scope, time, and environment. For example, developers tend to test what they perceive as representative scenarios without the benefit of a formal test plan. These representative scenarios usually are directed to a single feature or small set of features, rather than the feature or small set of features in the context of an overall application. In most cases, this approach is reasonable because the developer's primary responsibility is to add or enhance the feature, and therefore testing, while important, is a secondary consideration. Furthermore, because the developer often is limited to testing within his or her personal development environment, it usually is impractical for the developer to account for the large number of hardware and software environments in which end-users will put the feature to use.
Due to the limited nature of developer testing, most software development organizations include a dedicated software testing group. This software testing group is responsible for producing thorough test plans and then conducting tests in accordance with those test plans. Because the testing group's primary responsibility is testing, tests may be developed for individual features, as well as those individual features in the context of an overall application. Testing groups usually assemble a wide range of hardware and software environments that are representative of supported end-user environments.
In order to increase the amount of testing that can be performed; testing groups typically employ some form of automated testing. This allows a single tester to write test code for a particular feature within a particular environment so that the test can be repeated as often as desired. One drawback to automated testing, however, is the overhead associated with developing and maintaining tests for each relevant environment. With traditional automated software testing, tests are customized to each particular environment, which essentially requires writing a new test to cover a new environment. Furthermore, traditional automated software testing offers limited flexibility for combining one or more existing tests into a single group of tests, which typically requires writing a new combined test for each of the combinations of interest. Accordingly, methods, systems, and computer program products are desired for testing software components without explicitly having to specify each test or test environment.
BRIEF SUMMARY OF THE INVENTION
The present invention relates to methods, systems, and computer program products for testing software components without explicitly having to specify each test or test environment. In accordance with example implementations, a computer system for automated testing loads and parses a test file. Among other things, the test file contains various sections, including one or more code sections that identify one or more software components written to test the product, one or more locations sections that identify one or more locations to run the one or more software components, an expandable variation section that associates the one or more software components with the one or more locations, and an expansion section that defines rules for expanding the expandable variation section. From the expandable variation section, the computer system creates one or more expanded variation sections, each of which associates a particular one of the one or more software components with a particular one of the one or more locations. Then, for each particular software component and location, the computer system executes setup instructions to prepare for running the particular software component, then executes the particular software component, and finally executes cleanup instructions.
A variety of expansion algorithms may be used to expand the expandable variation section. For example, a list expansion algorithm may generate permutations from a list of one or more placeholders and a list of one or more substitution strings. A pair-wise expansion algorithm may generate unique combinations from a list of substitution strings and the number of substitution strings to be included in each combination. A data file expansion algorithm may replace one or more placeholders with a comma separated list of substitutes from a data file. A range algorithm may substitute for a placeholder all values within a range defined by a lower limit and an upper limit. Other types of expansion algorithms also may be used.
The test file may reference result comparators to use in comparing expected results to actual results written out during the testing process. The actual results are generated during the testing and the expected results are included in the test file. Once testing of a software component is completed, a referenced comparator performs a comparison between actual and expected results to determine if the software component is functioning properly. A log may be written to with virtually any testing information during the testing process. The log may be helpful in diagnosing problems with a particular test, and as a mechanism for documenting what testing has been performed.
The test file also may include group and set sections for grouping the expanded variation sections. When a group section is present, a group setup routine may be called prior to processing the group and a group cleanup routine may be called after processing the group. Optional setup and cleanup routines also may be called for each code and group section. Context and synchronization information may be shared between various groups and code sections as appropriate.
One or more parameter sections may be included within the test file. The parameter sections allow their data to be accessed from a code or group section that is within the same scope as the parameter section. For example, the parameters section may provide input values to a software component being tested. The test file may conform to one or more eXtensible Markup Language (XML) schemas.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. The features and advantages of the invention may be realized and obtained by means of the instruments and combinations particularly pointed out in the appended claims. These and other features of the present invention will become more fully apparent from the following description and appended claims, or may be learned by the practice of the invention as set forth hereinafter.
BRIEF DESCRIPTION OF THE DRAWINGS
In order to describe the manner in which the above-recited and other advantages and features of the invention can be obtained, a more particular description of the invention briefly described above will be rendered by reference to specific embodiments thereof which are illustrated in the appended drawings. Understanding that these drawings depict only typical embodiments of the invention and are not therefore to be considered as limiting its scope, the invention will be described and explained with additional specificity and detail through the use of the accompanying drawings in which:
FIG. 1 illustrates a basic logical architecture of an example test execution framework in accordance with the present invention;
FIGS. 2A-2B show relative execution order in accordance with example implementations of the present invention;
FIG. 3 shows an example embodiment of a test execution framework in accordance with the present invention;
FIGS. 4A-4C show example acts and steps for methods of testing software components in accordance with the present invention; and
FIG. 5 illustrates an example system that provides a suitable operating environment for the present invention.
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
The present invention extends to methods, systems, and computer program products for testing software components without explicitly having to specify each test or test environment. The embodiments of the present invention may comprise one or more special purpose and/or one or more general purpose computers including various computer hardware, as discussed in greater detail below.
FIG. 1 illustrates a basic logical architecture 100 for an example test execution framework in accordance with the present invention. Prior to discussing FIG. 1 in detail, an understanding of some basic terminology will be helpful. A portion (or code) is the smallest unit of code executed by the test execution framework. In one example embodiment, a portion corresponds to a class that implements an IPortion interface, including setup, run, and cleanup methods as described in more detail below. A location is the place where the portion or code runs. In this example test execution framework, locations specify a class that implements the portion in a test file which describes the tests to run.
The pseudo code example shown in Table I helps illustrate the relationship between locations and portions. Suppose, for example, that code with a client and a server communicating over sockets needs to be tested. The test may be divided as shown in Table I. TABLE I Server Setup open a socket listen on the socket accepts a connection Run receives N bytes of data Cleanup close the connection close the socket Client Setup open a socket connect to server Run send N bytes of data Cleanup close the connection The locations in this example are the client and the server. The portions are the pseudo code shown in italics. Notice that there are no limitations on where the client and server are to be run. For example, they could be on the same machine, two threads in the same process, or on difference machines. Conceptually, the test is the same.
Variations are one or more portions that together determine the action of a test. A variation is defined by associating what to run (code or portion) with where to run (location). For example, a variation may have a client and server portions that together execute the test. The client may send a message to the server, which validates the message. There could be a number of variations for the client/server test. One test might include three variations that vary in the number of bytes that are sent and received, such as 0 MB, 1 MB, and 5 GB. Each variation passes or fails separately, but if the client or server fails at any processing step, that portion of the test fails, which leads to the entire variation failing.
Variations are members of groups. A group handles things that a number of portions need. In this example test execution framework, a group is a class that implements an IGroup interface, including setup and cleanup methods. Continuing with the example above, consider how the server uses sockets. The server currently opens a new listening socket for each variation. This is not a particularly realistic scenario. Normally, a server would open one socket for listening and perform a number of accepts on that socket, not just one. Accordingly, the pseudo code from Table I can be modified as shown in Table II, where the open/close code is moved to a group setup so that it is run only once for all of the variations in a group. TABLE II MyGroup Location = Server Setup open a socket listen on the socket Cleanup close the socket Server (member of MyGroup) Setup accepts a connection Run receives N bytes of data Cleanup close the connection Client (member of MyGroup) Setup open a socket connect to server Run send N bytes of data Cleanup close the connection
Notice that the server location now only accepts a connection, receives the data, and closes the connection. The setup and cleanup of the listening socket occurs in the group setup and cleanup for the server location. Also notice that no change occurred in the client location. Since the server and client are both in the same variation, they are both members of MyGroup. However, there is nothing done by MyGroup for the client location so no code is specified.
A set is a logical grouping of variations. For example, a set could include all of the Kerberos security tests, or any other grouping that a test writer may desire. There is no code, such as setup and cleanup routines, associated with a set. Sets, however, may include parameters, as discussed in greater detail below.
With reference to FIG. 1 then, portions are the actual code that is executed by the framework. Accordingly, portions also may be referred to simply as code. Locations are where each portion runs. For example, portions 112, 132, 152, 172, and 192 run at location 120; portions 114134, 154, 174, and 194 run at location 140; and portions 116, 136, 156, 176, and 196 run at location 160. All portions in a location run in the same thread of execution. The actual physical location of locations 120, 140, and 160, i.e., machine, process, domain, and thread, are determined at runtime by the test execution framework.
Variations contains references to portions. For example, variation 110 references portions 112, 114, and 116; variation 130 references portion 132, 134, and 136; variation 150 references portions 152, 154, and 156; variation 170 references portions 172, 174, and 176; and variation 190 references portion 192, 194, and 196. Each portion runs some code and indicates a result. If all of the portions in a variation pass, then the variation passes. The portions in a variation all run in parallel.
One possible run of the case illustrated in FIG. 1 would be to have each location 120, 140, and 160 represent a separate machine. Another run could have each location on the same machine, but in different processes, or two locations on one machine in one process, and another location on another machine. All are valid and supported scenarios.
FIGS. 2A-2B show the relative execution order for groups, variations, and code in accordance with an example implementation of a test execution framework. FIG. 2A illustrates a location 200, executing a group 210 that includes variation 240, with code 220 and 230. First, the setup routine 212 for group 210 is run. Next, the setup routine 222 of code 220 for variation 240 runs. Following setup routine 222, the actual code for testing a software component, run routine 224 executes. Once run routine 224 executes, cleanup routine 226 runs, and processing of code 220 is complete. Similar to code 220, code 230 begins by running setup 232, followed by executing the actual code 234 for testing a software component, and then cleanup routine 236 runs. This same pattern repeats for all code that is within variation 240.
FIG. 2B illustrates relative execution order for multiple groups and variations. Note that each variation shows a consolidated setup, run, and cleanup routine for all portions referenced within the variation. Each group, group 1, group 2, and group 3, includes corresponding setup and cleanup routine. Processing begins with setup g1 for group 1, followed by setup g2 for group 2 and setup v1 for variation 1. After run v1 and cleanup v1 for variation 1, group 2 executes setup v2, run v2, and cleanup v2 for variation 2. Once all of the variations for group 2 have completed execution, cleanup g2 for group 2 runs. Next, setup g3 for group 3 runs, followed by setup v3, run v3, and cleanup v3 for variation 3. After variation 3, cleanup g3 for group 3 and cleanup g1 for group 1 execute.
Parameters are available to portions and groups. They are passed to each portion or group through the execution engine argument of the setup, run, and cleanup methods. Parameters are specified in the test file and are scoped as illustrated in Table III. TABLE III Global Locations Group Locations Set Locations Variation Location For example, a parameter that is specified at the set level is available to all portions within that set, but not to a portion in a different set. Notice that group does not have access to the set, variation, or portion level parameters because groups exist at a higher level than sets, variations, or portions.
It should also be pointed out here that there may be multiple location sections at multiple levels of a test file. The deeper scoped locations have the same identifier as the global locations. The deeper ones are only for adding parameters and default locations. Each of the deeper location nodes refers to corresponding global location nodes by the corresponding global location node's identifier.
As described in greater detail below, a simple test project may be used to illustrate test execution framework development. The test is for a stream reader class constructor that takes a string as an argument: - StreamReader(string);
First, the portion that will execute the test is shown in Table IV and described line by line in Table V. An eXtensible Markup Language (XML) test file to execute the portion is shown in Table VI and described line by line in Table VII. Some portions have been replaced with ellipses for ease of reading. TABLE IV 1- using System; 2- using System.IO; 3- using company.project.Test.Framework; 4- 5- namespace company.project.Test.Framework.Samples.Sample1 6- { 7- public class Client : IPortion 8- { 9- public void Setup(ExecutionEngine ee) 10- { 11- ee.Log.Trace("Test Setup"); 12- } 13- 14- public void Run(ExecutionEngine ee) 15- { 16- ee.Log.Trace("Test Run"); 17- try { 18- StreamReader sr = 19- new StreamReader((String) 20- ee.Context["FileName"]); 21- sr.Close( ); 22- ee.Results.Write("Success"); 23- } 24- catch 25- { 26- ee.Results.Write("Exception"); 27- } 28- 29- public void Cleanup(ExecutionEngine ee) 30- { 31- ee.Log.Trace("Test Cleanup"); 32- } 33- } 34- }
The portion shown in Table IV to execute the test is described line by line in Table V. TABLE V Line Description 3 This is the using statements needed to write a TEF portion 7 This is the class that implements the IPortion interface for the client Location 9 This is the Setup( ) method of the IPortion interface. In this case, we don't have any code needed. 11, 16, These log Trace messages into the log file. Depending on 31 the logging level, these may or may not be written out. 14 This is the Run( ) method of the IPortion interface. It actually executes the test. The Results will be evaluated and success will be determined 20 This gets the value of FileName from the Context object. See lines 22-25 and 44-47 of the TEF file to see this Parameter being defined 22 This writes the result "Success" to the results object. This will be compared to either line 34 or 56 of the TEF file to determine success, depending on which variation is run 29 This is the Cleanup( ) method of the IPortion interface. In this case, we don't have any code needed
The XML test file to execute the portion or code is shown in Table VI, below TABLE VI 1- <TestSpec> 2- <Locations> 3- <Location> 4- <ID>Local</ID> 5- <Description> ... </Description> 6- </Location> 7- </Locations> 8- <DefaultClassLocation> 9- <Assembly>...Sample1</Assembly> 10- <Namespace>...Sample1</Namespace> 11- </DefaultClassLocation> 12- <Sets> 13- <Set> 14- <ID>StreamReader Create</ID> 15- <Description> ... </Description> 16- <Variations> 17- <Variation> 18- <ID>Exists</ID> 19- <Level>Sanity</Level> 20- <Description> ... </Description> 21- <Parameters> 22- <Parameter> 23- <Key>FileName</Key> 24- <Value>Exists</Value> 25- </Parameter> 26- </Parameters> 27- <Locations> 28- <Location> 29- <ID>Local</ID> 30- <Code> 31- <Class>Client</Class> 32- </Code> 33- <Results> 34- <Result>Success</Result> 35- </Results> 36- </Location>
37- </Locations> 38- </Variation> 39- <Variation> 40- <ID>NotExists</ID> 41- <Level>Sanity</Level> 42- <Description> ... </Description> 43- <Parameters> 44- <Parameter> 45- <Key>FileName</Key> 46- <Value>Non-Existing</Value> 47- </Parameter> 48- </Parameters> 49- <Locations> 50- <Location> 51- <ID>Local</ID> 52- <Code> 53- <Class>Client</Class> 54- </Code> 55- <Results> 56- <Result>Exception</Result> 57- </Results> 58- </Location> 59- </Locations> 60- </Variation> 61- </Variations> 62- </Set> 63- </Sets> 64- </TestSpec>
The XML test file to execute the portion or code is described line by line in Table VII, below. TABLE VII Line Description 1 Opening tag 2-7 Locations defined for this test 3-6 The Local location. This is the only location for this test 4 This is the ID of the location. This is referenced by Variations which specify the code that is to run in each Location. Must be unique. 5 Long description of the Location 8-11 DefaultClassLocation. If code is defined without an assembly or namespace, then this assembly and namespace are used. 12-63 All of the Sets that will be defined in this test 13-62 Definition of the StreamReader Create Set. There is only one set in this example 14 This is the ID of the Set. It must be unique. This can be referenced from the command line to run a specific Set. 15 Long description of the Location. 16-61 Variations that comprise the Set. There are two variations in this Set. 17-38, A Variation in the Set. 39-60 18, 40 This is the ID of the Variation. It must be unique within the Set. 19, 41 Level of the Variation. This can be referenced from the command line to specify which Variations to run. For example, this could be BVT, or Sanity, or Stress . . . 15, 42 Long description of the Variation 21-26, Parameters section. This contains the Parameters 43-48 that are defined for this Variation. 22-25, This defines a Parameter. It's "Key" is FileName, 44-47 and its Value is "Exists" (or "Non-Existing"). See Code line 20 above to see it being accessed. 27-37, This defines all of the Locations and code (Portions) 49-59 that have to run in those locations for this Variation. This variation only associates code with one location. 28-36, This defines the only Location and its properties 50-58 (code etc) for this Variation. 29, 40 This specifies the ID of the Location that this code has to run at. The code runs at Location "Local". See lines 3-6 to see this Location being defined. 31, 53 This defines the actual Code that needs to be run to execute this Portion. Note that only the class is given. The Assembly and Namespace are taken from the DefaultClassLocation in line 8-11. 33-35, This defines the Results to be expected for this 55-57 Portion. See lines 22 and 26 in the Code to see the actual results being filled in.
As described above, groups implement an IGroup interface, portions implement an IPortion interface. Both groups and portions also may implement an IOptionalSetup interface. Each of these interfaces is illustrated in Table VIII. TABLE VIII interface IGroup { void Setup(ExecutionEngine ee); void Cleanup(ExecutionEngine ee); } public interface IPortion { void Setup(ExecutionEngine ee); void Run(ExecutionEngine ee); void Cleanup(ExecutionEngine ee); } public interface IOptionalSetup { void OptionalSetup(ExecutionEngine ee); void OptionalCleanup(ExecutionEngine ee); } As indicated above in connection with FIG. 2B, setup for the IGroup interface is called before any of the portion code and cleanup is called after all of the portion code for the group is complete. Throwing an exception from either method indicates failure. For the IPortion interface, setup is called first, run is called second, and cleanup is called last. Run may be called multiple time in a stress test scenario. Setup and cleanup indicate failure by throwing exceptions. Run puts strings into a results object, and failure is derived by comparing the results object with expected results included in the test file.
The IOptionalSetup interface is an interface that can be implemented by groups and portions. OptionalSetup is called before setup and OptionalCleanup after cleanup. The two methods indicate failure by throwing an exception. If OptionalSetup fails, setup is not executed, and if cleanup fails, OptionalCleanup will not be executed. Since IOptionalSetup interface methods can be skipped from the command line by using the command line options /nosetup and /nocleanup, these methods are well-suited for persistent changes, such as writing to a file or configuration information registry. Using /nosetup or /nocleanup may be helpful while reproducing and debugging test failures, such as when it is desirable to examine machine state after the failure or to put the machine in a certain state before the test case.
FIG. 3 shows an example embodiment of a test execution framework 300 in accordance with the present invention. Test execution framework 300 includes execution engine 310, test code 320, and service layer 330. Test code 320 includes a variety of tests, including test 1 322, test 2 324, and test n 326. As described in further detail below, the extensible service layer 330 includes logger 331, expansion algorithms 332, results 333, context information 335, synchronization information 336, comparators 337, location information 338, other 339, etc. By making service layer 330 extensible, test execution framework 300 can be customized and enhanced to address a variety of testing needs and circumstances that previously required. Default implementations are provided for each component shown in service layer 330, but a tester may change the code assembly and narmespace to point to any desired customized implementations. It should be noted here that execution engine may refer to the code that actually executes a test, as in execution engine 310, and/or an object as described in greater detail below.
As indicated in the tables above, an execution engine parameter is passed to the setup, run, and cleanup functions of the IGroup, IPortion, and IOptionalSetup interfaces. The following objects are accessible from the execution engine parameter: Context, SharedContext, Logger, Results, MyLocationID, LocationInformation, IsPortionReadyTofinish, IsTimeToFInishPortion, WaitForMyPortionFinish, and WaitForSharedContextItem. Each of these objects is described in more detail below.
The context and shared context 335 are string addressable relational arrays of objects. They are used for passing information into and between portions and groups. The context and shared context are accessed as follows, assuming ee to be the execution engine: - ee.Context["key"]=Value;
- Value=ee.Context["key"];
Note that setting a key to null removes the data from the top of the scoped context and will uncover the value from the previous context if the key exists in the previous context. A shared context is assigned by the previous code or portion, whereas context information can originate in a test file or be assigned by a previous higher code. In other words, context may not be assigned by peer portions at the same level, but may be assigned, for example, from a group for code within the group. Context is valid for the current level and all deeper levels, but disappears when the portion cleanup finishes. Shared context is valid for current and all subsequent code.
Contexts are implemented as a stack of contexts. When the context at the top is asked for a parameter, it performs a lookup on itself, and if the parameter is not found, the current context ask the next context in the stack for the parameter. Contexts are added to the stack as environment variables first, and then configuration parameters, and finally parameters defined in the test file. Accordingly, parameters defined in the test file override configuration parameters, which override environment variables.
Logger 331 is used to log test information to a log. Along with the test information message, the time and log level also are logged. Available log levels include always, trace, warning, and error. As indicated above, logger 331 is extensible and may include one or more custom loggers to cover a variety of logging requirements. Method names for the Logger 331 correspond to these levels, and are shown below in Table IX. The log level for a test run may be given as a command line parameter. TABLE IX public void Always( string message ); public void Error( string message ); public void Warn( string message ); public void Trace( string message ); Message is the string that will be put into the log file. Assuming ee is the execution engine parameter, logging may be accessed as follows: - ee.Logger.Trace("Starting open");
- ee.Logger.Error("Open FAILED");
Results 333 is used to write out results for determining the pass or fail results of a portion. For the example test execution framework 300, the portion should only output things through results 333 that can be statically compared to a string, as the expected results are given as a string in the test file. As indicated above, however, service layer 330 is extensible and provides for extensible comparators 337 to compare actual and expected results. Accordingly, the results may take any of a variety of formats, based on the comparators that are available for a particular test execution framework implementation. Example methods for results 333 are given below in Table X. TABLE X void WriteMultiple( object[ ] results); Calls Write(object o) for each object o in the object[ ] array void Write( string str); Writes out the given string to the result object void Write( string str, params object[ ] args); Writes out the object[ ] array using the passed in string as a formatting string void Write( object o); Writes out the object o as a string using its ToString method Assuming ee is the execution engine parameter, results may be written as follows: - ee.Results.Write("Received {0} bytes", NumBytes);
Location information 338 is a table that contains location information for all locations that are being used in a test. Each entry includes the following string fields: ID—unique location ID; name—location name; and, MachineName—machine name for the machine where the location is execution. Location information is indexed by the location ID, which as indicated above is a string. MyLocationID is the location ID of the current portion. Usage is as follows: - string S=ee.LocationInformation["Server"].MachineName;
- string S=ee.MyLocationID;
There are four synchronization objects 336: IsPortionReadyToFinish, IsTimeToFinishPortion, WaitForMyPortionFinish, and WaitForSharedContextItem. Each of these objects is shown with more detail below in Table XI. TABLE XI public bool IsPortionReadyToFinish; ee.IsPortionReadyToFinish = true; public bool IsTimeToFinishPortion; while (!IsTimeToFinishPortion) { Thread.Sleep(1000); } public void WaitForMyPortionFinish( ); WaitForMyPortionFinish( ); ee.Logger.Trace("Portion Done"); public bool WaitForSharedContextItem( string Key, string Value ); public bool WaitForSharedContextItem( string Key, string Value, string Message ); public bool WaitForSharedContextItem( string Key, string Value, string Message, int maxTotalTimeToWait ); Key This is the name of the key that you want to wait for in the shared context. Value This is the value of the key that you want to wait for. Message This is a message that is printed out to the log if the wait takes longer than 1 second. This is for debugging. The default value for this message is Portion <myLocationID> waiting for key "<key>" to have value "<value>" maxTotalTimeToWait
This is the time to wait for the key to get the specified value. The default is Timeout.Infinite. if (!WaitForSharedContextItem("ServerReady", "true")) { ee.Results.Write("WaitForSharedContextItem - ServerReady - true, failed); return; }
Expansion algorithms 332 may be used in test files. Expansion algorithms allow a test writer to specify rules for creating sections of the test file, rather than having to explicitly list all of the sections. As in other areas of service layer 330, these expansion algorithms 332 are extensible and may be customized to handle a variety of expansion needs with relatively little effort. A simple example is shown below in Tables XII A-C and XIII A-B. The example uses a list expand algorithm to take the name METHOD and replace it with "TCP" and "Remoting" in the test file. List expansion can be used to create new sets and variations by putting these chunks of XML in the correct location. The locations that are allowed to be expanded will be described later. TABLE XII A 1 <ExpansionInstructions> 2 <Code> 3 <Class>ListExpansionAlgorithm</Class> 4 </Code> Lines 2-4 above indicate the class to load to perform the expansion. TABLE XII B 5 <Details xsi:type="ListExpansionDetails"> 6 <ExpansionPlaceholders> 7 <Placeholder>METHOD</Placeholder> 8 </ExpansionPlaceholders> Line 7 tells the expansion algorithm what string is being used as a placeholder for the substitutions. TABLE XII C 9 <List> 10 <ListItem> 11 <Substitution> 12 <Placeholder>METHOD</Placeholder> 13 <Value>Tcp</Value> 14 </Substitution> 15 </ListItem> 16 <ListItem> 17 <Substitution> 18 <Placeholder>METHOD</Placeholder> 19 <Value>Remoting</Value> 20 </Substitution> 21 </ListItem> 22 </List> 23 </Details> 24 </ExpansionInstructions> Lines 10-15 and 16-21 give substitution values for the placeholder. This will create two different replacements, "Tcp" and "Remoting."
The expansion algorithm can be used in various places within the test file, such as the following four places described below. Placing this code within a <Set> node will make copies of the set with the expansion being the only change. Placing this code inside a <Variation> node will make copies of the variation with the expansion being the only change. Placing this expansion code inside a <Sets> node has the same effect as placing it inside every <Set> node. Similarly, placing the expansion code inside the <Variations> node has the same effect as placing it inside every <Variation> node within the current <Set>. An example use of the expansion instruction illustrated in Tables XII A-C is shown in Tables XIII A-B. TABLE XIII A <Sets> <Set> <EXPANSION NODE FROM ABOVE> <ID>Min %METHOD%</ID> <Variations> <Variation> <ID>MinTest1</ID> <Group>%METHOD%</Group> <Locations> <Location> <ID>Client</ID> .... </Location> <Location> <ID>Server</ID> .... </Location> </Locations> </Variation> </Variations> </Set> </Sets>
The example use of the expansion instruction illustrated in Table XIII A will produce the test file fragment shown in Table XIII B after the expansions has run. Notice that there are now two sets, one with the <ID> "Min Tcp" and the other with the <ID> of "Min Remoting." TABLE XIII B <Sets> <Set> <ID>Min Tcp</ID> <Variations> <Variation> <ID>MinTest1</ID> <Group>Tcp</Group> <Locations> <Location> <ID>Client</ID> .... </Location> <Location> <ID>Server</ID> .... </Location> </Locations> </Variation> </Variations> </Set> <Set> <ID>Min Remoting</ID> <Variations> <Variation> <ID>MinTest1</ID> <Group>Remoting</Group> <Locations> <Location> <ID>Client</ID> .... </Location> <Location> <ID>Server</ID> .... </Location> </Locations> </Variation>
</Variations> </Set> </Sets>
More generally, the list expansion algorithm takes a list of placeholders and a list of substitution strings, and creates new sets or variations by replacing the placeholders with the substitution strings. TABLE XIV <ExpansionInstructions> <Code> <Assembly>Company.Xws.Test.Framework</Assembly> <Class>Company.Xws.Test.Framework.Expansion.ListExpansionAlgorithm</Class> </Code> <Details xsi:type="ListExpansionDetails"> <ExpansionPlaceholders> <Placeholder>String-1</Placeholder> <Placeholder>String-2</Placeholder> .... <Placeholder>String-N</Placeholder> </ExpansionPlaceholders> <List> <ListItem> <Substitution> <Placeholder>String-1</Placeholder> <Value>String-val-1.1</Value> </Substitution> <Substitution> <Placeholder>String-2</Placeholder> <Value>String-val-1.2</Value> </Substitution> .... <Substitution> <Placeholder>String-N</Placeholder> <Value>String-val-1.N</Value> </Substitution> </ListItem> <ListItem> <Substitution> <Placeholder>String-1</Placeholder> <Value>String-val-2.1</Value> </Substitution> <Substitution> <Placeholder>String-2</Placeholder> <Value>String-val-2.2</Value> </Substitution> .... <Substitution>
<Placeholder>String-N</Placeholder> <Value>String-val-2.N</Value> </Substitution> </ListItem> .... <ListItem> <Substitution> <Placeholder>String-1</Placeholder> <Value>String-val-3.1</Value> </Substitution> <Substitution> <Placeholder>String-2</Placeholder> <Value>String-val-3.2</Value> </Substitution> .... <Substitution> <Placeholder>String-N</Placeholder> <Value>String-val-3.N</Value> </Substitution> </ListItem> </List> </Details> </ExpansionInstructions>
The pair-wise expansion algorithm takes an option "order" and a list of substitutions. The <Order>N</Order> tag is optional and defaults to two. This means that if the order specifies two, every possible combination of two substitutions will be tested. Similarly, if the order is three, every possible combination of three substitutions will be tested. If the order is set to zero or minus one, every possible combination of all substitutions will be tested. Substitutions are expressed as a name and a list of possible values. The name is equivalent to a placeholder in the list expansion algorithm. Any reference to %name% in the relevant section of a test file will be replaced. An example of pair-wise expansion is shown in Table XV. TABLE XV <ExpansionInstructions> <Code> <Assembly>Company.Test.Framework</Assembly> <Class>company.Test.Framework.Expansion.PairwiseExpansionAlgorithm</Class> </Code> <Details xsi:type="PairwiseExpansionDetails"> <Order>2</Order> <Factor> <Name>METHOD</Name> <Choices> <ValueChoice>Tcp</ValueChoice> <ValueChoice>Remoting</ValueChoice> </Choices> </Factor> <Factor> <Name>Function</Name> <Choices> <ValueChoice>Min</ValueChoice> <ValueChoice>Max</ValueChoice> </Choices> </Factor> </Details> </ExpansionInstructions>
Often it is desirable to substitute a range of integer values, e.g., 1 through 20, for a placeholder. It would be cumbersome, however, to use the list expansion algorithm to write twenty substitution elements. The range expansion algorithm takes a lower limit and an upper limit of a range and substitutes all the values in the range for the placeholder. Optionally, a step size may be specified to determine the amount by which successive values differ. The syntax for range expansion is shown in Table XVI. RangeSubstitution identifies the placeholder or string to be substituted, with /@min specifying the lower limit of the range, /@max specifying the upper limit of the range, and /@step specifying the incremental step size of the substitution values. TABLE XVI <ExpansionInstructions> <Code> <Assembly>Company.project.Test.Framework</Assembly> |