SoapUI on Steroids
SoapUI on Steroids
Using groovy's power and a use case based approach to build robust automation frameworks in SoapUI.
About the Book
This book is my attempt to share a lot of cool use cases and features that we build during working on a complex project on SoapUI. In this book, I will share on how to do most of the things in the open source version of SoapUI, that SoapUI says are only possible in the pro version.
Table of Contents
1. First things first . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1 Credits and acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 What to expect and what not to . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 For best user experience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2. Why this book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3. What will you learn? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4. Who is this book intended for? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5. Book approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
6. How to begin? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.1 All you need is a problem to solve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.2 Need based learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.3 Why need based learning? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6.4 A note on procedural learning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
7. An example case study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
7.1 My problem statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.2 Slicing it into smaller problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.3 To stub or to integrate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.4 Test and build approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.5 Simple rule of testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
8. Install SoapUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
9. Tool Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
10. Project setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
11. Driver Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
11.1 Sample Driver script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
11.2 How does a real life (anonymized) project driver script looks like? . . . . . . . . . . . . . 35
12. Project Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
12.1 SetUp Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
12.1.1 Reset Project Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
12.1.2 Reset TestSuite Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
12.1.3 Parse and Set Project Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
12.1.4 Parse and Set login details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
12.1.5 Parse and Set TestSuite properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
12.1.6 Create temp folders used in framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
12.2 TearDown Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
12.3 A note on Project Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
13. Test Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
14. Test Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
14.1 Create a data driven framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
14.2 Groovy Test Step design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
14.3 Set a project or TestSuite property at run time . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
14.4 Read a project or TestSuite property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
14.5 Parse and set properties from external file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
14.6 Set flag files to talk between systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
14.7 Pass end point URLs to Soap Request steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
14.8 Set response ID from Soap Request step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
14.9 Backup request and response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
14.10 Pass variables between scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
14.11 Parse request and store in a array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
14.12 Connecting to a DB2 or Oracle database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
14.13 Create, Read, Update, Delete values in table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
14.14 FTP files between mainframe and windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
14.15 Move files using command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
14.16 decode encoded Base 64 and save payload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
14.17 Validate a SHA256 hash key . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
14.18 Compare date with String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
14.19 Export input file string to input file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
14.20 Extract payload data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
14.21 Oracle connection from SoapUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
14.22 Set Get Reset Test Case properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
14.23 Find number of days between two dates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
14.24 Increment a timestamp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
14.25 Finding decimal place for amount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
14.26 Formatting an amount as per local . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
14.27 Run a excel macro from SoapUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
14.28 An important Note . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
15. Test Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
16. Reporting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
16.1 Storing test results for each execution step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
16.2 Capture time stamp for Test Run . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
16.3 Create a folder to store test results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
16.4 Store log results in a txt file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
16.5 Auto numbering result log files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
16.6 Move files to results folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
16.7 Updating overall TS run result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
16.8 Collect index number of all test steps in a test case . . . . . . . . . . . . . . . . . . . . . . . . 162
17. Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
18. Test Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
19. Version Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
20. Summary and Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
21. Tips and learnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
21.1 Limitation on number of lines of code per script . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
21.2 Testing negative scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
21.3 Testing positive scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them