A WsdlTestSuite object representing your web service test suite is accessible directly via the testSuite variable available to Setup and TearDown scripts and through methods of some of its children (e.g., test cases) and the WsdlTestSuiteRunner object. Through the WsdlTestSuite object, you can access test cases belonging to the test suite and test suite properties.
A few (and really only a few-- there are many many more) of its methods:
- getName() : returns the name of the test suite as a String
- getTestCaseList() : returns a Java List of WsdlTestCase objects corresponding to test cases contained in the suite
- getTestCaseCount() : returns a count of the test cases contained in the suite (as an integer)
- getTestCaseAt(int index) : given an integer representing the zero-based index of a test case in the test suite, returns an object corresponding to that test case
- getTestCaseByName(String name) : returns the test case contained in the test suite with name name
- getProperties() : returns a Map of the test suite's properties
- getPropertyList() : returns a Java List of TestProperty objects corresponding to the test suite's properties
- getPropertyAt(int index) : given an integer representing the zero-based index of a property in the test suite's list of properties, returns a TestProperty object corresponding to that property
- getProperty(String name) : returns a TestProperty object corresponding to the property with name name
- getPropertyValue(String name) : returns the value of the property with name name
- setPropertyValue(String name, String value) : sets the value for the property with name name to value value
Here's the starting test suite properties for a sample test suite with two test cases simply named TestCase1 and TestCase2:
A sample Setup script (at the suite level) for this test suite that illustrates some of these methods:
//Get the test suite name log.info("Test Suite Name: " + testSuite.getName()) //Get the number of test cases in the suite log.info("Test Case Count: " + testSuite.getTestCaseCount()) //Get test suite's test cases as a list myTCList = testSuite.getTestCaseList() for(i in myTCList){ log.info("Test Case Name: " + i.getName()) } //Get the test case at index 0 log.info("Test Case at index 0: " + testSuite.getTestCaseAt(0).getName()) //Get the test case named TestCase2 - a silly example for illustrative purposes only! log.info("Getting TestCase2 by Name: " + testSuite.getTestCaseByName("TestCase2").getName()) //Get the value of Property1 log.info("Value of Property1: " + testSuite.getPropertyValue("Property1")) //Change the value of Property1 - we'll see the change in TearDown testSuite.setPropertyValue("Property1", "Prop1Changed")
The resulting output in the script log:
A sample Teardown script for the same test suite illustrating some more methods:
//Get properties as a Map myPropertiesMap = testSuite.getProperties() //Note that Property1 reflects the value we set it to at the end of the SetUp script log.info("Property1 value = " + myPropertiesMap["Property1"].getValue()) //Set Property1 back to PropertyValue1 testSuite.setPropertyValue("Property1","PropertyValue1") //Get properties as a List myPropList = testSuite.getPropertyList() //Property1 value reflects change back to PropertyValue1 for(prop in myPropList){ log.info(prop.getName() + " = " + prop.getValue()) } //Get a property by index myTestProperty = testSuite.getPropertyAt(2) log.info("Property at index 2: " + myTestProperty.getName() + " = " + myTestProperty.getValue()) //Get a property by name myNamedTestProperty = testSuite.getProperty("UName") log.info("UName value = " + myNamedTestProperty.getValue())
The resulting output in the script log:
No comments:
Post a Comment
Please be respectful of others (myself included!) when posting comments. Unfortunately, I may not be able to address (or even read) all comments immediately, and I reserve the right to remove comments periodically to keep clutter to a minimum ("clean" posts that aren't disrespectful or off-topic should stay on the site for at least 30 days to give others a chance to read them). If you're looking for a solution to a particular issue, you're free to post your question here, but you may have better luck posting your question on the main forum belonging to your tool's home site (links to these are available on the navigation bar on the right).