Unit testing a SOA Suite CompositeImportance of testing and tool usage and responsabilityRobert van Mölken, 19-03-2013 1
2 What you will come to know• Why testing an important facet is of product development• Options for testing your code• Which opties are commonly used for testing SOA applications – SOA Suite Test Suite Framework • Unit testing / simulation of a SOA composite and components – SoapUI (optional combined with DBUnit / Groovy) • Unit testing with use of datasources and XPath matching• How do these solution stack up to each other• Conclusion about what we know now
3" A good unit test will not onlyflush out problems before youget close to production, but it will help regression test your system as well.”
4 Why testing an important facet is More expensive to fix defects in later phases Too many (IT) projects failTwo reasons are budget and quality control Ideal defect removal by phase
5 5 reasons why Unit Testing is Important and fun 2. Use as a template for future process and/or code changes3. Leads to a Better design 4. Know how the code works and reacts on different scenario’s
6 5 reasons why Unit Testing is Important and fun5. Confidence in Your code and “Refactor without Fear”
7 Options for testing your code Front-endJava backend Middleware
8 Unit testing with SOA Suite testsuites frameworkResponsability of SOA Suite within test cycle
9 Creating a Test SuiteRight-click on testsuites folder in SOA project to create a new suite
10 Creating a Composite TestRight-click on tests folder in SOA project to create a new test
11 Emulating a Service CallService operations can be emulated, via manual value or imported file
12 Emulating a Service ResponseService response can be emulated, if not service is really called
13 Asserting Input / OutputRequest and response messaged can be asserted on expected data
14 Component testing (PS5+)Since PS5 it is possible to assert data of BPEL component activities
15 Component data assertionAsserting is possible on almost every activity. Based on primitives, xml similar, etc. It is also possible to assert the execution count.
16 Reporting (enterprise manager)Tests can be run via the enterprise manager. Which reports the results.
(Unit) testing with SoapUIResponsability of SoapUI within test cycle
19 Setup tests within SoapUI (1/4)SoapUi project based on a service WSDL Add multiple service bindings to project
20 Setup tests within SoapUI (2/4)Execute single operations without assertions Create testsuite(s) as a empty template or based on a service binding
21 Setup tests within SoapUI (3/4)Generating a testsuite is easy by using a wizard with a few options
22 Setup tests within SoapUI (4/4)After generating you will have a testsuite with testcase(s) and teststep(s)
23 SoapUi Teststeps• Test step based on a SOAP service request• Test step based on a Groovy script• Test step for defining testcase properties• Test step for transfering property values• Test step for defining a conditionele goto• Test step for defining a delay (in miliseconds)• Test step for defining a call to another testcase (and other testsuite)
24 SoapUi Teststeps• Test step based on a REST request• Test step based on a HTTP request (GET, POST, PUT…)• Test step based on a MOCK service response• Test step based on a JDBC query to database• Test step based on a AMF (action message, AS3) request• Test step to create a manual action of human interaction
25 SoapUi Pro Teststeps• Test step to setup a datasource which retrieves a dataset which can be used in other test steps• Test step for defining a datasource loop• Test step for exporting property values for reporting• Test step for dynamically defining properties (current data/time)• Test step to assert/validate property values, request or response messages.
26 Datasource step when using SoapUI Free Commandline with Apache Ant it’s possible to start SoapUI Within SoapUi you can define properties which can be overwritten by AntA property can be a reference to a file which can be read by groovy Alternatively is the use of a DBUnit step in the Ant script to insert datasets
How do they stack up to each otherAspect SOA Suite SoapUI (DBUnit)Setup Environment + +-Setup Testcases + +Easy to adjust / clone - ++Real unit testing ++ +-Integration testing - ++Continuous integration + ++Reporting ++ +Assertion of data -- ++
Conclusion:Unit testing is important, cuts time & costs and gives a developer confidence!