The document describes a testing tool that allows performing various types of tests including load, functional, security and API compatibility tests. It supports popular protocols and data formats, provides built-in statistics and allows writing tests using drag-and-drop or scripts. The tool also allows simulating network services, recording HTTP traffic and has a supportive community.
Handwritten Text Recognition for manuscripts and early printed texts
Testwarez 2013 - Warsztat SoapUI
1. Testy obciążeniowe
Testy funkcjonalne
Wsparcie dla popularnych
protokołów
Tworzenie testów metodą
Drag and Drop
Testy bezpieczeostwa
Wbudowane statystyki
Możliwośd używania
skryptów
Wsparcie dla SSL
Automatyzacja
Nagrywanie HTTP
Symulacja usług
sieciowych
Wsparcie społeczności
Sprawdzanie zgodności
ze standardami
2. Agenda
• Acceptance Test-Driven Development
FEATURE:
IN ORDER to manage contacts from various applications
AS an international corporation
I WANT a service with REST API
• Some examples of soapUI usage
• Some examples of Groovy scripts
Resources: http://bit.ly/16FdgyK
4. Scenario 1: Fetching all contacts
GIVEN service available at base url
AND database containing 5 contacts
WHEN I send GET request for /contacts resource
THEN I should receive response with code 200
AND 5 entity tags containing contact details
5. Displaying information in soapUI
// Static text
log.info "Displaying text in soapUI script log"
// Dynamic text
def query = "q=Jacek"
log.info "Parameter query: ${query}"
log.info "Parameter query: " + query
// soapUI related variables
log.info "Request for ${mockRequest.path}"
log.info "method: ${mockRequest.httpRequest.method}"
log.info "with params: ${mockRequest.httpRequest.queryString}"
def dir = context.expand('${projectDir}');
log.info "Project saved in ${dir}"
6. Scenario 2: Fetching filtered contacts
GIVEN service available at base url
AND database provisioned according to the example
WHEN I send GET request for /contacts?q=<query>
THEN I should receive response containing <#> contacts
Example:
| query
| rysiek
| Steve
| XNAS
|#
|1
|2
|0
|
|
|
|
7. Returning file content in response
import com.eviware.soapui.impl.wsdl.mock.WsdlMockResult
def docRoot = mockRunner.mockService.docroot
if ( queryString == "q=Steve" ) {
mockRunner.returnFile (
mockRequest.httpResponse,
new File("${docRoot}contacts-q-Steve")
)
mockRequest.httpResponse.status = 200
return new WsdlMockResult( mockRequest )
}
9. Scenario 3: Fetching contact by contactId
GIVEN service available at base url
WHEN I send GET request for /contacts/<contactId>
THEN I should receive response with <code>
AND content of message should contain <details>
Example:
| contactId | code
| 103fbd
| 200
| 000000 | 500
| details
|
| Bill Gates |
| Fault
|
10. soapUI API
http://www.soapui.org/apidocs
// Getting reference to project object
def tc = testRunner.testCase
def testStep = tc.testSteps["TestStep name"]
// Setting or getting properties
tc.setPropertyValue("contactId", "103fbd" )
testStep.getPropertyValue("ResponseAsXml")
// Executing test step
def result = testStep.run( testRunner, context )
//if( result.status == TestStepStatus.OK ){}
// Running in load context
if( context.LoadTestContext != null )
no = context.RunCount as Integer
12. Groovy and XML
// Parsing text
def rootNode = new XmlSlurper().parseText(
'<root><one a1="uno!"/><two>Some text!</two></root>'
)
// Reading elements
assert rootNode.name() == 'root'
assert rootNode.one[0].@a1 == 'uno!'
assert rootNode.two.text() == 'Some text!'
rootNode.children().each { assert it.name() in ['one','two'] }
13. Scenario 4: Adding contact
GIVEN service available at base url
AND having contactId 103fbd in the database
WHEN I send PUT request containing <contactId>
THEN I should receive response with <status code>
AND I should be able to get added
Example:
| contact details
| 103fbf
| 103fbd
| status code
| 200
| 403
|
|
|
14. Groovy and files
// Opening file
def file = new File("tmp")
//Writing content of request to file
file << mockRequest.httpRequest.inputStream
// Reading from file
file.readLines()
// Other methods
file.exists()
file.renameTo("newFIleName")
15. Groovy and XML
<entry>
<id>103fbd60efd5725</id>
<category>CEO</category>
<title type="text">Bill Gates</title>
<firstname>Bill</firstname>
<lastname>Gates</lastname>
</entry>
// Opening xml file
def entry = new XmlSlurper().parse(file)
// Reading elements
def id = entry.id.text()
def category = entry.category as String
det titleType = entry.title.@type.text()