HHaynes
15 years agoContributor
getting log.info out of scripts in loadUI during runtime?
So - as part of my scripts I've been logging info out in order to see where things were going with conditional logic in my Groovy scripts. I would like (actually, I need) to see this logging while the tests are running. How do I do that?
Example of a conditional script with logging below:
Example of a conditional script with logging below:
import com.eviware.soapui.model.testsuite.TestRunner
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def threadId = Thread.currentThread().getId() as String
def holder = groovyUtils.getXmlHolder( "AddTicketsNewCart#ResponseAsXml" );
def ticketsExist = holder["exists(//response/cart)"];
def getTicketsFault = holder["exists(//response/error)"];
def request = testRunner.testCase.getTestStepByName( "Properties" );
def ticketCount = request.getProperty( "ticketCount" );
def standingTicketPollingCount = request.getProperty( "ticketPollingCount" );
def ticketCountMax = request.getProperty( "totalSpotlightEvents" );
if (Integer.parseInt(ticketCount.value) > Integer.parseInt(ticketCountMax.value))
{
testRunner.fail("Add ticket loop reached max count. Test fail.")
}
else
{
if (ticketsExist == 'true')
{
def ticketPrice = holder.getNodeValue("//response/cart/totals/grand")
groovyUtils.setPropertyValue( "Properties", "ticketPrice", ticketPrice )
log.info("[${threadId}] Ticket price ${ticketPrice}. Going to GetCart1.")
log.info("[${threadId}] Ticket added. Going to GetCart1 to verify.")
testRunner.gotoStepByName( "GetCart1" )
}
else
{
def ticketPollingURL = holder.getNodeValue("//response/polling_url")
groovyUtils.setPropertyValue( "Properties", "ticketPollingURL", ticketPollingURL )
def newTicketPollingCount = Integer.parseInt(standingTicketPollingCount.value) +1 as String;
groovyUtils.setPropertyValue( "Properties", "ticketPollingCount", newTicketPollingCount );
log.info("[${threadId}] AddTicket polled [count = ${newTicketPollingCount}]. Cycling to HTTP polling request.")
testRunner.gotoStepByName( "delayForTicketPollingInterval" )
}
}