SoapUI
- Mainly used for functional testing
- Main concepts in SOAPUI testing:
Web service mocking
Web service inspection
Functional tests of web services
Web service load tests
1) Right click on Project Node in the navigator and select
import project
2) Select SOAPUI project dialog will open.
Select sample-soapui-pro-project.xml from tutorial folder
3) Sample project will be shown in SOAPUI navigator
Web service mocking is very useful in projects where
implementation of the web service has not started
or is not finished.
1) To add a mockservice, right click on interface icon and
select Generate MockService
2) Generate Mockservice dialog will open
3) Enter name of your mock service and click OK
4) Mockservice will now be successfully generated
5) Open the mockservice by double clicking on it
6) Browse through different interfaces in MockService;
login, logout, search and buy and see what we do with
different requests.
7) Click run button to start the MockService
8) You now see MockService running on port 8080
Webservice inspection
Good support for web service inspection can be very
important early in your testing process when you want to find out how web
service works.
1. Lets start by some inspection. Go to interface inspector
by double clicking SampleServiceSoapBinding node. You see Interface Inspector
open on the SoapUI desktop.
2. This is structured way of looking at your WSDL. Just
browsing the XML of the WSDL is very cluttered
and WSDL often is to complicated too look at in its entirety
and therefore it is seldom done, resulting in
lower WSDL understanding. WSDL are so complicated people
dont read it, and remember, WSDL is a specification and how well you use it depends
on how well you understand it.
This is serious problem early on in projects, people in the
project dont understand Contract. SoapUI interface viewer is great tool for
solving this problem
3. Expand the login and double click on Request1.
You will see loginRequest open on the soapUI desktop.
The request already uses the username Login and the password
Login123.
4. Click on the Run button to submit the request.
5. You should now see response on the response panel.
Functional tests of Web services
We have create three different TestSuites all containing
different TestCases. TestCase is made up of several steps called TestSteps.
Structure of the SoapUI project is like this:
- Project
- Interface
- TestSuites
TestCases
TestSteps
LoadTests
-MockServices
Let us examine a functional test in a testCase.
1. Expand Sample Simple TestSuite and double click
on Simple Login and Logout w.Properties steps.
2. Test case consists of five test steps.
3. You can also click Description tab in order to see
in test documentation.
4. Step consists of three different types of testSteps:
- one PropertyStep
- two TestRequests
- two PropertyTransfer Steps
PropertySteps: Store properties for later use. In our case
it is username and password to login
Test Requests: actual requests to server. In this case login
and logout.
PropertyTransfers: step used to move property between
different steps. This might be from Property
step to request like step Property transfer: Move Username
and Password does,
or to move properties from Test Request to another,like the
step Property Transfer: Move sessionID does.
5. Double click on TestStep Property Transfer: Move Username
and Password.
6. TestStep editor will now open on SoapUI desktop
7. Important property in SoapUI tests is the Assertions.
Assertions are made in Test Requests
and is for validating that response is what we expected.
8. In TestStep we have four assertions, asserting
different things:
SOAP Response: that response is a SOAP response
Schema Compliance: It complies with Schema
Not SOAP fault: That is isnt SOAP fault.
XPATH Match: Validates that certain element has value
expected
Test Run:
- Lets run it.
- Press play button and test will run and test case progress
bar will be full and green
- Does it turn red after only a step?
Dont forget to start the MockService.
Web Service load tests:
- Something very useful in SoapUI is ability to create
LoadTests.
- Earlier you are able to run load tests, earlier you can
discover any performance issues.
- In SoapUI you create LoadTest by choosing functional
test, right clicking it and saying new
loadtest. Done
- This makes SoapUI loadtest extra good since immediately
enable you to load test the functionality not that the Web Service can respond quickly to same
Request over and over again.
LoadTests are byproducts of functional tests.
1) Go to TestSuite Sample expanded TestSuite and the
TestCase Search and Buy TestCase. There are four
different LoadTests in that TestCase one for each LoadTest
strategy. Choose LoadTest: Simple Strategy LoadTest.
2) Lets configure the test.
- first thing to configure is Simple Strategy is Limit,
number of second we want test to run.
- second thing is Threads, no of threads used.
for now we use 1 thread.
- third thing to configure is TestDelay, which
sets number of milliseconds our base delay will be.
In the test now we set to 200 milliseconds.
- fourth item is the random variable, which sets how
the Test delay should be changed at random,
value 0.5 means it should be half, that is between
100 and 300 milliseconds.
3) Now lets run it
4) As you see number of test are continuously updated.
5) You can even see the graph button and see graph of test
run.
6) In the SoapUI LoadTests, you can also do LoadTest
Assertions.
One of the important assertions is the Max Errors step.
This will allow maximum number of errors allowed
in test run, which will lead us to the final
example, discovering an error in our MockService
An error in our MockService
- finally we get one error we put in MockService
on purpose.
1) Go to TestSuite Sample TestSuite fails if we dont get
faults
and the TestCase TestCase: Searching after Logging out
LoadTests.
There you will find load test called LoadTest with Multiple
Tests will fail.
2) Open it and run it. After a time this test will fail.
As multiple users are simultaneously logging in with same
username, which is not allowed by the MockService.
No comments:
Post a Comment