|
Not sure if this answers your question but here's a patch from what I'm
working on - it extracts some values from a dbUnit xml file and stores
them in WebtestProperties and then uses them to test rendered content
in the webpage. As an aside, I logged to a local file (which is what
you were asking about), as I had no luck getting diagnostic feedback
from either echo or print. my steps: <groovy>
def logFile = new File('./webtest.log')
logFile.append("\nTest Start\n")
def testData = new XmlParser().parse( new File('../../config/InHouseTesting.xml') )
def customerId = 1001
def testCustomer = testData.customerDetails.find{it['@customerID']==customerId}
def testCustomerId = testCustomer.'@customerID'
def testCustomerName = testCustomer.'@customerName'
logFile.append("${testCustomerId} - ${testCustomerName}")
// I can't get groovy's print to appear - some classpath dilemma no doubt
// print "${testCustomerId} - ${testCustomerName}"
step.setWebtestProperty('test_customer_id', testCustomerId)
step.setWebtestProperty('test_customer_name', testCustomerName)
logFile.append("\nTest End\n")
</groovy>
<verifyProperty name="test_customer_id" text="1001" />
<verifyProperty name="test_customer_name" text="Canoo WebTest Customer 1" />
<verifyText description="dbUnit text must be present in the current webpage"
text="#{test_customer_name}" />
<!-- these don't render the properties properly - I don't know why not? -->
<echo message="Test Customer Name = ${test_customer_name}" />
<echo message="Test Customer Name = #{test_customer_name}" />
Here's a sample chopped down from the dbUnit file (standard dbUnit file that loads xml into db for testing) <?xml version='1.0' encoding='UTF-8'?> <dataset> <customerDetails customerID="1001" customerName="Canoo WebTest Customer 1" contactName="Contact Name 1" contactAddress="1 Address St" /> <customerDetails customerID="1002" customerName="Canoo WebTest Customer 2" contactName="Contact Name 2" contactAddress="2 Address St" /> <customerDetails customerID="1003" customerName="Canoo WebTest Customer 3" contactName="Contact Name 3" contactAddress="3 Address St" /> <customerDetails customerID="1004" customerName="Canoo WebTest Customer 4" contactName="Contact Name 4" contactAddress="4 Address St" /> <userDetails username="webtest01" customerID="1001" fullName="WebTest User" userTypeSystem="user" /> <userDetails username="webtest02" customerID="1001" fullName="WebTest Administrator" userTypeSystem="administrator" /> <siteDetails siteID="1001" customerID="1001" siteName="Site 1001" /> <siteDetails siteID="1002" customerID="1001" siteName="Site 1002" /> <siteDetails siteID="1003" customerID="1001" siteName="Site 1003" /> </dataset> on 13/07/06 01:46 [EMAIL PROTECTED] said the following:
|
- [Webtest] How to print/log in WebTest? dlundin
- Re: [Webtest] How to print/log in WebTest? + dbUnit to We... Rob Manthey

