Transfer list between Groovy test steps (SoapUI)Skip Test Step in SOAPUI through groovyRetrieve response from a “Run Test Step”, using SoapUI/ Groovy?Step assertion based on different step result - soapUI (run test case and test step from script assertion)Groovy Script and Property transfer in soapUISoapUI passing Groovy Properties aroundProperties transfer in soapui using groovyGroovy script for test steps in SoapUIhow to make other test steps pass/fail from groovy test step in SOAPUIGroovy (SoapUI) choose which request are compatible with deployed API and use themSoapUI enable list of test steps (Groovy)
Why is Google approaching my VPS machine?
Can a Resident Assistant be told to ignore a lawful order?'
Why does "git status" show I'm on the master branch and "git branch" does not in a newly created repository?
What is the meaning of [[:space:]] in bash?
What is this green alien supposed to be on the American covers?
Should I be able to keep my company purchased standing desk when I leave my job?
Interviewing with an unmentioned 9 months of sick leave taken during a job
Wordplay subtraction paradox
Was Jacobi the first to notice the ambiguity in the partial derivatives notation? And did anyone object to his fix?
Is there an English equivalent for "Les carottes sont cuites", while keeping the vegetable reference?
Vienna To Graz By Rail
''Habitable'' planet close to a star
Why did Steve Rogers choose this character in Endgame?
How could an animal "smell" carbon monoxide?
Which GPUs to get for Mathematical Optimization (if any...)?
How can a drink contain 1.8 kcal energy while 0 g fat/carbs/protein?
Was Apollo 13 radio blackout on reentry longer than expected?
Do dragons smell of lilacs?
FPGA CPUs, how to find the max speed?
How to create array of references?
Can you perfectly wrap a cube with this blocky shape?
How to find location on Cambridge-Mildenhall railway that still has tracks/rails?
How Can I Process Untrusted Data Sources Securely?
How to have a continuous player experience in a setting that's likely to favor TPKs?
Transfer list between Groovy test steps (SoapUI)
Skip Test Step in SOAPUI through groovyRetrieve response from a “Run Test Step”, using SoapUI/ Groovy?Step assertion based on different step result - soapUI (run test case and test step from script assertion)Groovy Script and Property transfer in soapUISoapUI passing Groovy Properties aroundProperties transfer in soapui using groovyGroovy script for test steps in SoapUIhow to make other test steps pass/fail from groovy test step in SOAPUIGroovy (SoapUI) choose which request are compatible with deployed API and use themSoapUI enable list of test steps (Groovy)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have one test case which is called (started and finished) before every run of other test cases. It is something like 'test data preparation' test case. Output from this test case is list with some elements, list looks like this:
def list = ['Login', 'Get Messages', 'Logout', etc.]
List is different on every run. I need to transfer this list from 'test data preparation' test case to other test cases. Transfer will be between two Groovy scripts.
How to transfer list between two Groovy test steps in SoapUI?
groovy soapui
add a comment |
I have one test case which is called (started and finished) before every run of other test cases. It is something like 'test data preparation' test case. Output from this test case is list with some elements, list looks like this:
def list = ['Login', 'Get Messages', 'Logout', etc.]
List is different on every run. I need to transfer this list from 'test data preparation' test case to other test cases. Transfer will be between two Groovy scripts.
How to transfer list between two Groovy test steps in SoapUI?
groovy soapui
The phrasing of your question leads me to believe you are looking for some sort of established "best practice". I don't think that exists. If you are merely looking for a what-is-your-best-experience solution, I may be able to help you with an answer.
– Steen
Mar 26 at 9:24
@Steen , I will be glad for any working solution
– Marek Masek
Mar 26 at 9:41
add a comment |
I have one test case which is called (started and finished) before every run of other test cases. It is something like 'test data preparation' test case. Output from this test case is list with some elements, list looks like this:
def list = ['Login', 'Get Messages', 'Logout', etc.]
List is different on every run. I need to transfer this list from 'test data preparation' test case to other test cases. Transfer will be between two Groovy scripts.
How to transfer list between two Groovy test steps in SoapUI?
groovy soapui
I have one test case which is called (started and finished) before every run of other test cases. It is something like 'test data preparation' test case. Output from this test case is list with some elements, list looks like this:
def list = ['Login', 'Get Messages', 'Logout', etc.]
List is different on every run. I need to transfer this list from 'test data preparation' test case to other test cases. Transfer will be between two Groovy scripts.
How to transfer list between two Groovy test steps in SoapUI?
groovy soapui
groovy soapui
edited Mar 26 at 10:00
Marek Masek
asked Mar 26 at 9:12
Marek MasekMarek Masek
356 bronze badges
356 bronze badges
The phrasing of your question leads me to believe you are looking for some sort of established "best practice". I don't think that exists. If you are merely looking for a what-is-your-best-experience solution, I may be able to help you with an answer.
– Steen
Mar 26 at 9:24
@Steen , I will be glad for any working solution
– Marek Masek
Mar 26 at 9:41
add a comment |
The phrasing of your question leads me to believe you are looking for some sort of established "best practice". I don't think that exists. If you are merely looking for a what-is-your-best-experience solution, I may be able to help you with an answer.
– Steen
Mar 26 at 9:24
@Steen , I will be glad for any working solution
– Marek Masek
Mar 26 at 9:41
The phrasing of your question leads me to believe you are looking for some sort of established "best practice". I don't think that exists. If you are merely looking for a what-is-your-best-experience solution, I may be able to help you with an answer.
– Steen
Mar 26 at 9:24
The phrasing of your question leads me to believe you are looking for some sort of established "best practice". I don't think that exists. If you are merely looking for a what-is-your-best-experience solution, I may be able to help you with an answer.
– Steen
Mar 26 at 9:24
@Steen , I will be glad for any working solution
– Marek Masek
Mar 26 at 9:41
@Steen , I will be glad for any working solution
– Marek Masek
Mar 26 at 9:41
add a comment |
2 Answers
2
active
oldest
votes
As I understand it:
- You have one TestCase, which you call from every other TestCase.
- I assume this is done using a "Run TestCase" teststep?
- You would like to be able to pass a list of strings
- As I read it, parameters go one way. From the "external testcase" and back to the calling testcase. There is no "input" from each testcase to this "external testcase"?
The Groovy Script in your "external testcase" may then generate a String result, which in turn can be converted to something like an Array or ArrayList of Strings.
This could be a string with values separated by ;
def result = ""
result += "Entry1;"
result += "Entry2;"
result += "Entry3;"
// You may want to add a line of code that removes the last ;
return result
This result will then be easily retrieved from Groovy Scripts elsewhere, by adding a few lines of code.
If the Groovy Script is placed in another TestCase, but in the same TestSuite, you may retrieve the result using:
def input = testRunner.testCase.testSuite.getTestCaseByName("Name of TestCase").getTestStepByName("Groovy Script Name").getPropertyValue("result")
If it is placed in a TestCase in a different TestSuite, you may use:
def input = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite Name").getTestCaseByName("Test Case Name").getTestStepByName("Groovy Script Name").getPropertyValue("result")
and then loop over the input doing something like:
for (def s : input.split(";"))
log.info s
// Do your stuff here
I hope that makes sense...? :)
add a comment |
from groovy step 1 you shall return the list:
def list = ['Login', 'Get Messages', 'Logout']
return list
from groovy step 2 you can get this returned list
def result = context.expand( '$Groovy Script 1#result' )
list = result.tokenize('[,] ')
list.each
log.info it
note that you get a string that you have to convert back to a list (tokenize).
I did this with SOAPUI pro.
Another way (ugly) would be to store the list in a custom property in groovy script 1 (using testRunner.testCase.setPropertyValue("myList",list.toString())
and to recover it in groovy step 2 (testRunner.testCase.getPropertyValue("myList")
I hope that will help
EDIT : if list elements contain spaces
this is not very clean and I hope someone will help to provide something better but you can do the following :
list = "['Login - v1', 'Get Messages - v2', 'Logout - v1']"
list = list.replace(''','"')
def jsonSlurper = new groovy.json.JsonSlurper()
list = jsonSlurper.parseText(list)
list.each
log.info it
Alex
Thank you, transfer works properly, but when I will get list which looks like this:['Login - v1', 'Get Messages - v2', 'Logout - v1']
thentokenize('[,] ')
won't work properly. It separates it to more elements. And If I try to use this:tokenize('[,]')
then I need to use elements with.trim()
, because there is a whitespace before every element.
– Marek Masek
Mar 26 at 12:12
ah, this is a problem, indeed ... I'll add some code
– A.Joly
Mar 26 at 13:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353398%2ftransfer-list-between-groovy-test-steps-soapui%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As I understand it:
- You have one TestCase, which you call from every other TestCase.
- I assume this is done using a "Run TestCase" teststep?
- You would like to be able to pass a list of strings
- As I read it, parameters go one way. From the "external testcase" and back to the calling testcase. There is no "input" from each testcase to this "external testcase"?
The Groovy Script in your "external testcase" may then generate a String result, which in turn can be converted to something like an Array or ArrayList of Strings.
This could be a string with values separated by ;
def result = ""
result += "Entry1;"
result += "Entry2;"
result += "Entry3;"
// You may want to add a line of code that removes the last ;
return result
This result will then be easily retrieved from Groovy Scripts elsewhere, by adding a few lines of code.
If the Groovy Script is placed in another TestCase, but in the same TestSuite, you may retrieve the result using:
def input = testRunner.testCase.testSuite.getTestCaseByName("Name of TestCase").getTestStepByName("Groovy Script Name").getPropertyValue("result")
If it is placed in a TestCase in a different TestSuite, you may use:
def input = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite Name").getTestCaseByName("Test Case Name").getTestStepByName("Groovy Script Name").getPropertyValue("result")
and then loop over the input doing something like:
for (def s : input.split(";"))
log.info s
// Do your stuff here
I hope that makes sense...? :)
add a comment |
As I understand it:
- You have one TestCase, which you call from every other TestCase.
- I assume this is done using a "Run TestCase" teststep?
- You would like to be able to pass a list of strings
- As I read it, parameters go one way. From the "external testcase" and back to the calling testcase. There is no "input" from each testcase to this "external testcase"?
The Groovy Script in your "external testcase" may then generate a String result, which in turn can be converted to something like an Array or ArrayList of Strings.
This could be a string with values separated by ;
def result = ""
result += "Entry1;"
result += "Entry2;"
result += "Entry3;"
// You may want to add a line of code that removes the last ;
return result
This result will then be easily retrieved from Groovy Scripts elsewhere, by adding a few lines of code.
If the Groovy Script is placed in another TestCase, but in the same TestSuite, you may retrieve the result using:
def input = testRunner.testCase.testSuite.getTestCaseByName("Name of TestCase").getTestStepByName("Groovy Script Name").getPropertyValue("result")
If it is placed in a TestCase in a different TestSuite, you may use:
def input = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite Name").getTestCaseByName("Test Case Name").getTestStepByName("Groovy Script Name").getPropertyValue("result")
and then loop over the input doing something like:
for (def s : input.split(";"))
log.info s
// Do your stuff here
I hope that makes sense...? :)
add a comment |
As I understand it:
- You have one TestCase, which you call from every other TestCase.
- I assume this is done using a "Run TestCase" teststep?
- You would like to be able to pass a list of strings
- As I read it, parameters go one way. From the "external testcase" and back to the calling testcase. There is no "input" from each testcase to this "external testcase"?
The Groovy Script in your "external testcase" may then generate a String result, which in turn can be converted to something like an Array or ArrayList of Strings.
This could be a string with values separated by ;
def result = ""
result += "Entry1;"
result += "Entry2;"
result += "Entry3;"
// You may want to add a line of code that removes the last ;
return result
This result will then be easily retrieved from Groovy Scripts elsewhere, by adding a few lines of code.
If the Groovy Script is placed in another TestCase, but in the same TestSuite, you may retrieve the result using:
def input = testRunner.testCase.testSuite.getTestCaseByName("Name of TestCase").getTestStepByName("Groovy Script Name").getPropertyValue("result")
If it is placed in a TestCase in a different TestSuite, you may use:
def input = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite Name").getTestCaseByName("Test Case Name").getTestStepByName("Groovy Script Name").getPropertyValue("result")
and then loop over the input doing something like:
for (def s : input.split(";"))
log.info s
// Do your stuff here
I hope that makes sense...? :)
As I understand it:
- You have one TestCase, which you call from every other TestCase.
- I assume this is done using a "Run TestCase" teststep?
- You would like to be able to pass a list of strings
- As I read it, parameters go one way. From the "external testcase" and back to the calling testcase. There is no "input" from each testcase to this "external testcase"?
The Groovy Script in your "external testcase" may then generate a String result, which in turn can be converted to something like an Array or ArrayList of Strings.
This could be a string with values separated by ;
def result = ""
result += "Entry1;"
result += "Entry2;"
result += "Entry3;"
// You may want to add a line of code that removes the last ;
return result
This result will then be easily retrieved from Groovy Scripts elsewhere, by adding a few lines of code.
If the Groovy Script is placed in another TestCase, but in the same TestSuite, you may retrieve the result using:
def input = testRunner.testCase.testSuite.getTestCaseByName("Name of TestCase").getTestStepByName("Groovy Script Name").getPropertyValue("result")
If it is placed in a TestCase in a different TestSuite, you may use:
def input = testRunner.testCase.testSuite.project.getTestSuiteByName("Test Suite Name").getTestCaseByName("Test Case Name").getTestStepByName("Groovy Script Name").getPropertyValue("result")
and then loop over the input doing something like:
for (def s : input.split(";"))
log.info s
// Do your stuff here
I hope that makes sense...? :)
answered Mar 26 at 10:07
SteenSteen
6702 silver badges12 bronze badges
6702 silver badges12 bronze badges
add a comment |
add a comment |
from groovy step 1 you shall return the list:
def list = ['Login', 'Get Messages', 'Logout']
return list
from groovy step 2 you can get this returned list
def result = context.expand( '$Groovy Script 1#result' )
list = result.tokenize('[,] ')
list.each
log.info it
note that you get a string that you have to convert back to a list (tokenize).
I did this with SOAPUI pro.
Another way (ugly) would be to store the list in a custom property in groovy script 1 (using testRunner.testCase.setPropertyValue("myList",list.toString())
and to recover it in groovy step 2 (testRunner.testCase.getPropertyValue("myList")
I hope that will help
EDIT : if list elements contain spaces
this is not very clean and I hope someone will help to provide something better but you can do the following :
list = "['Login - v1', 'Get Messages - v2', 'Logout - v1']"
list = list.replace(''','"')
def jsonSlurper = new groovy.json.JsonSlurper()
list = jsonSlurper.parseText(list)
list.each
log.info it
Alex
Thank you, transfer works properly, but when I will get list which looks like this:['Login - v1', 'Get Messages - v2', 'Logout - v1']
thentokenize('[,] ')
won't work properly. It separates it to more elements. And If I try to use this:tokenize('[,]')
then I need to use elements with.trim()
, because there is a whitespace before every element.
– Marek Masek
Mar 26 at 12:12
ah, this is a problem, indeed ... I'll add some code
– A.Joly
Mar 26 at 13:54
add a comment |
from groovy step 1 you shall return the list:
def list = ['Login', 'Get Messages', 'Logout']
return list
from groovy step 2 you can get this returned list
def result = context.expand( '$Groovy Script 1#result' )
list = result.tokenize('[,] ')
list.each
log.info it
note that you get a string that you have to convert back to a list (tokenize).
I did this with SOAPUI pro.
Another way (ugly) would be to store the list in a custom property in groovy script 1 (using testRunner.testCase.setPropertyValue("myList",list.toString())
and to recover it in groovy step 2 (testRunner.testCase.getPropertyValue("myList")
I hope that will help
EDIT : if list elements contain spaces
this is not very clean and I hope someone will help to provide something better but you can do the following :
list = "['Login - v1', 'Get Messages - v2', 'Logout - v1']"
list = list.replace(''','"')
def jsonSlurper = new groovy.json.JsonSlurper()
list = jsonSlurper.parseText(list)
list.each
log.info it
Alex
Thank you, transfer works properly, but when I will get list which looks like this:['Login - v1', 'Get Messages - v2', 'Logout - v1']
thentokenize('[,] ')
won't work properly. It separates it to more elements. And If I try to use this:tokenize('[,]')
then I need to use elements with.trim()
, because there is a whitespace before every element.
– Marek Masek
Mar 26 at 12:12
ah, this is a problem, indeed ... I'll add some code
– A.Joly
Mar 26 at 13:54
add a comment |
from groovy step 1 you shall return the list:
def list = ['Login', 'Get Messages', 'Logout']
return list
from groovy step 2 you can get this returned list
def result = context.expand( '$Groovy Script 1#result' )
list = result.tokenize('[,] ')
list.each
log.info it
note that you get a string that you have to convert back to a list (tokenize).
I did this with SOAPUI pro.
Another way (ugly) would be to store the list in a custom property in groovy script 1 (using testRunner.testCase.setPropertyValue("myList",list.toString())
and to recover it in groovy step 2 (testRunner.testCase.getPropertyValue("myList")
I hope that will help
EDIT : if list elements contain spaces
this is not very clean and I hope someone will help to provide something better but you can do the following :
list = "['Login - v1', 'Get Messages - v2', 'Logout - v1']"
list = list.replace(''','"')
def jsonSlurper = new groovy.json.JsonSlurper()
list = jsonSlurper.parseText(list)
list.each
log.info it
Alex
from groovy step 1 you shall return the list:
def list = ['Login', 'Get Messages', 'Logout']
return list
from groovy step 2 you can get this returned list
def result = context.expand( '$Groovy Script 1#result' )
list = result.tokenize('[,] ')
list.each
log.info it
note that you get a string that you have to convert back to a list (tokenize).
I did this with SOAPUI pro.
Another way (ugly) would be to store the list in a custom property in groovy script 1 (using testRunner.testCase.setPropertyValue("myList",list.toString())
and to recover it in groovy step 2 (testRunner.testCase.getPropertyValue("myList")
I hope that will help
EDIT : if list elements contain spaces
this is not very clean and I hope someone will help to provide something better but you can do the following :
list = "['Login - v1', 'Get Messages - v2', 'Logout - v1']"
list = list.replace(''','"')
def jsonSlurper = new groovy.json.JsonSlurper()
list = jsonSlurper.parseText(list)
list.each
log.info it
Alex
edited Mar 26 at 13:57
answered Mar 26 at 10:24
A.JolyA.Joly
1,3521 gold badge10 silver badges19 bronze badges
1,3521 gold badge10 silver badges19 bronze badges
Thank you, transfer works properly, but when I will get list which looks like this:['Login - v1', 'Get Messages - v2', 'Logout - v1']
thentokenize('[,] ')
won't work properly. It separates it to more elements. And If I try to use this:tokenize('[,]')
then I need to use elements with.trim()
, because there is a whitespace before every element.
– Marek Masek
Mar 26 at 12:12
ah, this is a problem, indeed ... I'll add some code
– A.Joly
Mar 26 at 13:54
add a comment |
Thank you, transfer works properly, but when I will get list which looks like this:['Login - v1', 'Get Messages - v2', 'Logout - v1']
thentokenize('[,] ')
won't work properly. It separates it to more elements. And If I try to use this:tokenize('[,]')
then I need to use elements with.trim()
, because there is a whitespace before every element.
– Marek Masek
Mar 26 at 12:12
ah, this is a problem, indeed ... I'll add some code
– A.Joly
Mar 26 at 13:54
Thank you, transfer works properly, but when I will get list which looks like this:
['Login - v1', 'Get Messages - v2', 'Logout - v1']
then tokenize('[,] ')
won't work properly. It separates it to more elements. And If I try to use this: tokenize('[,]')
then I need to use elements with .trim()
, because there is a whitespace before every element.– Marek Masek
Mar 26 at 12:12
Thank you, transfer works properly, but when I will get list which looks like this:
['Login - v1', 'Get Messages - v2', 'Logout - v1']
then tokenize('[,] ')
won't work properly. It separates it to more elements. And If I try to use this: tokenize('[,]')
then I need to use elements with .trim()
, because there is a whitespace before every element.– Marek Masek
Mar 26 at 12:12
ah, this is a problem, indeed ... I'll add some code
– A.Joly
Mar 26 at 13:54
ah, this is a problem, indeed ... I'll add some code
– A.Joly
Mar 26 at 13:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55353398%2ftransfer-list-between-groovy-test-steps-soapui%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The phrasing of your question leads me to believe you are looking for some sort of established "best practice". I don't think that exists. If you are merely looking for a what-is-your-best-experience solution, I may be able to help you with an answer.
– Steen
Mar 26 at 9:24
@Steen , I will be glad for any working solution
– Marek Masek
Mar 26 at 9:41