How to call some common Groovy code from multiple assertions?
I am really getting that hang of soapUI's scripting capabilities. They are totally groovy, indeed! :-)
I have meanwhile unified my test cases such, that they all execute the same code-snippet which loads a regex from a file and then asserts whether the received response matches that regex. The only thing that differs between all my test-cases is the name of the file from which to read the applicable regex. For each testcase there is one file containing the regexp that the response of that testcase has to match.
The next step in simplifying things would be that all assertions call the exactly same piece of code. I would then not have to copy-paste the same code into each Script Assertion's code field any more (or just some minimalistic of code icentical for all assertions, like
call common_assertion_code(<name-of-testcase>)
For this I still need the following pieces:
- Where should I best place such a piece of groovy code that is to be used by multiple test-suites?
- How can I call that common piece of code from the assertion's code-snippet?
- How do I access the TestCase's name from within the assertion's code-snippet?
- How can I pass than name from the calling assertion code to the called common code?
Regards,
M.
Hi,
Don't know if you saw this recent post, but despite the title, this might be similar to what you're asking about?
Outlines a [resolved] discussion on how to include a custom Groovy (or Java) library (jar file) by adding it to the bin/ext folder, importing its classes and calling them from scripts.
If you need me to elaborate on any of it or try to give examples I can,
Regards,
Rupert