SoapUI – Properties using Groovy

//*CODE STARTS
//To GET THE TIME STAMP IN DIFFERENT FORMATS
//*
 
def sdf = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
log.info (sdf.format( new Date()))
 
def dff = new java.text.SimpleDateFormat("yyyy-dd-MM hh:mm:ss")
log.info (dff.format( new Date()))
 
def dtt = new java.text.SimpleDateFormat("yyyy-dd-MM")
log.info (dtt.format( new Date()))
 
 
//*
//TO GET THE DEFAULT PROPERTIES FROM SOAP UI
//*
 
 
 
//TO get the Project Name
def username = testRunner.testCase.testSuite.project.name
log.info (username)
 
//To get the Test Suite Name
def username1 = testRunner.testCase.testSuite.name
log.info (username1)
 
//TO get the Test Case Name
def username2 = testRunner.testCase.name
log.info (username2)
 
//TO get the Test Step Name
def username3 = context.getCurrentStep().getLabel()
log.info (username3)
 
 
 
//*
//To GET AND SET CUSTOM PROPERTIES IN SOAP UI
//*
 
 
 
//TO SET THE CUSTOM TEST CASE PROPERTY
testRunner.testCase.setPropertyValue( "MyProp", 'someValue' )
 
//TO GET THE CUSTOM PROPERTY THAT THE USER HAS CREATED IN TEST CASE
def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )
log.info(testCaseProperty)
 
//TO SET THE CUSTOM TEST SUITE PROPERTY
testRunner.testCase.testSuite.setPropertyValue( "MyProp", 'someValue' )
 
//TO GET THE CUSTOM PROPERTY THAT THE USER HAS CREATED IN TEST SUITE
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )
log.info(testSuiteProperty)
 
//TO SET THE CUSTOM PROJECT PROPERTY
testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", 'someValue' )
 
//TO GET THE CUSTOM PROPERTY THAT THE USER HAS CREATED IN PROJECT
def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )
log.info(projectProperty)
 
//CODE ENDS HERE
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s