Showing posts with label properties in soapUI. Show all posts
Showing posts with label properties in soapUI. Show all posts

Wednesday, June 15, 2011

Groovy 7 - getStatus & getError message of each assertion in a teststep

In one of the blog post, somebody asked me how they can get the status of each individual assertion of a test step. So on my way to office, i managed to comeup with below is the script which will extend (rather append) the existing code written in blog post - "Groovy 6 - clone test step assertion using Groovy script in soapUI".

Please note, that the below provided script can be extended/merged with other script shared. For instance, you can place few code lines from the script and iterate through all the teststep inside a testcase.

Keeping watching/reading this space, soon i will be sharing the blogs on - communicating with JXL API (free Excel API) & interaction with database using the Groovy.

/*
@Title : Gr-ooooooo-vy VII
@Author : Pradeep Bishnoi
@Description : Get the status of each assertion inside a specific test step.
*/

import com.eviware.soapui.model.testsuite.Assertable
def project = context.testCase.testSuite.project
def testSuite = project.getTestSuiteAt(1)
def testCase = testSuite.getTestCaseAt(0)
def testStepSrc = testCase.getTestStepByName("myTestStepName")
def counter = testStepSrc.getAssertionList().size()

for (count in 0..<counter)
{

log.info("Assertion :" + testStepSrc.getAssertionAt(count).getName() + " :: " + testStepSrc.getAssertionAt(count).getStatus())
error = testStepSrc.getAssertionAt(count).getErrors()
if (error != null)
{
log.info(error[0].getMessage())
}
log.info("---------------------------- Line to seperate each assertion status in logs -----------------")
}

I would appreciate your valuable comments and other relevant inputs.  Keep sharing & be happy :-)

Thursday, June 02, 2011

Groovy 6 - clone test step assertion using Groovy script in soapUI

Yesterday, I found one interesting question in eviware forum [thread] : seeking the information about replicating the "Clone Assertion" feature from soapUI Pro into the soapUI open source using the groovy. So i thought of trying my hand on the same and shared below is the working piece of code to achieve the same.

P.S. : I have also updated the eviware forum thread and people who 'hates' blog can read the solution in the thread. And thanks to the user for raising this question in forum :-)

Initialize:
# Create 2 property at testcase level named "sourceTestStep" & "targetTestStep" respectively.
# Always copy and paste the name of teststep when update the value of newly defined property, so as to reduce the possibility of TYPO error.
# Create a groovy test step then paste the below code and run the test step. Done!

/*  
@Title : Gr-oooooo-vy 6
@Author : Pradeep Bishnoi
@Description : Clone all the assertion from TestStep [SourceTestStep proptery] into the target TestSTep [TargetTestStep property] by executing a groovy test step.
*/

import com.eviware.soapui.model.testsuite.Assertable
def project = context.testCase.testSuite.project
def testSuite = project.getTestSuiteAt(1)
def testCase = testSuite.getTestCaseAt(0)
def sourceTestStep = context.expand( '${#TestCase#SourceTestStep}' )
def targetTestStep = context.expand( '${#TestCase#TargetTestStep}' )

def testStepSrc = testCase.getTestStepByName(sourceTestStep)
def testStepTrgt = testCase.getTestStepByName(targetTestStep)
def counter = testStepSrc.getAssertionList().size()
for (count in 0..<counter)
{
    testStepTrgt.cloneAssertion(testStepSrc.getAssertionAt(count), testStepSrc.getAssertionAt(count).getName())
}

Wednesday, February 23, 2011

"Default" & "Custom" Properties - soapUI

In soapUI, we have different levels at which we can define or find the properties. User defined properties can be used to make the testing simpler and less time consuming by directly updating the property values without (resulting in changed request) updating each individual request. We can broadly categorize properties as # "Default" and "User-Defined" properties. Now when these properties are associated in soapUI at different level they provide different details.

Default properties : These are the set of properties which comes by default with every soapUI installation. We can change the values of these properties (not in every case) & consume as when needed.

User-Defined properties : These are the set of properties which the end user defines as per his requirement. It can be used a temporary storage for validating the end result of any test (like in assertion).  


Below is the list of different level of properties :

# Global Properties : specify/define the properties associated with installed version of soapUI. These properties can be access across the project/test suites/ test cases and so on.

# Project Properties : specify the properties associated with the current project. This property can be used by all the subset (test suite, test case, test step, script) of the project.

# Test Suite Properties : specify the properties associated with the current test suite. This property can be used by all the subset (test case, test step, script) of the test suite.

# Test Cases properties : specify the properties associated with the current test case. This property can be used by all the subset (test step, script) of the test cases.

# Test Step properties : specify the properties associated with the current test step. This property can be used by all the subset (test step, property transfer, script) of the test steps.


The expression to be used in the web service request (xml view) for the consuming any properties are :


OR just open the web service request where you want to call the available property & right click on the screen. Then navigate to Get Data... item in context menu and select the required property. Attached is image:










 Will cover some real time examples in the upcoming videos only for user-defined properties.