Ask a Question

How to read the current executing excel row-column in a Groovy script test step?

SOLVED
cnanju
Occasional Contributor

How to read the current executing excel row-column in a Groovy script test step?

Hi ,
I am using excel file as data source.
How to read the current executing excel column in a Groovy script test step?

I tried right click and GetData option but log.info is showing empty.

Also how to see the logs of script which were executed during the loop?

 

PFA .png for the snapshot

1 ACCEPTED SOLUTION

Accepted Solutions
cnanju
Occasional Contributor

Re: How to read the current executing excel row-column in a Groovy script test step?

Hi nmrao,

 

                      Thanks for elaborating the question. What you have explained above is exactly what I was looking at.

With little bit of playing around with the "SoapUI NG Pro" I could generate the script to read a particular column from the currently executing row.

 

                   Now here is my test case's steps:

  1. Groovy script Test Step: Read column from excel to property (defined in test case)
  2. Execute a Parameterized Rest request  getting value from the property
  3. Groovy script Test Step: read the response and compare that with the response/expected value in the excel column along with some business validation check using assert

I am glad that "SOAP UI Pro /Ready! API 1.9.0" has done a wonderful job of "generating the script to read data from data source for the currently executing row". Here is the steps to do that

  • Just right click on the Groovy Script Test Step editor,
  • Click On "GetData" 
  • Select the data source from where to read the data, in my case it was the added excel file's column
  • editor will ask for some meaningful parameter name, enter and click OK

That's all you are done with the Groovy script which will read the column from a data source for the currently executing row.

I guess it's one of the top features which should have been listed or added as video demo mentioning how to work with Data source.

This whole thing is my personal favorite and I call it Dynamic data driven test, as I am able to test almost anything with this approach. Many a thanks to SOAP UI Pro team for building such a wonderful feature. I am thrilled.

View solution in original post

4 REPLIES 4
TanyaYatskovska
Community Manager

Re: How to read the current executing excel row-column in a Groovy script test step?

Hi Cnanju,

 

I'm not sure if this information is available during the test execution. @Community, what do you think? Is it possible to implement?

 

---------
Tanya Yatskovskaya
SmartBear Community and Education Manager


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
nmrao
Community Hero

Re: How to read the current executing excel row-column in a Groovy script test step?

Can you please show the screen shot of your test case with test steps?

 

By the way, what is your use case?



Regards,
Rao.
nmrao
Community Hero

Re: How to read the current executing excel row-column in a Groovy script test step?

Do you mean to consider such an enhancement?

Here is what I think the possible use case could be :
Generally, data from a data source is used in a Request type step such as SOAP / REST / JDBC / HTTP etc. Once, the response is received, the same data can be used for assertion. In Pro edition, it is possible to assert using different type of Assertions such as xpath, message content etc. Having said that, it might be the case that the assertion is complex and one needs to use Script Assertion where user wants to access the current record data of data source. This is very much applicable to Groovy Script test step as well if there is some thing more to be achieved by the user.

If the data (each row from source) can be accessible inside a request step, then it should be quite possible to be able to access the same in Groovy Script test step or Script Assertion as well provided the current convention is changed.

For example, there might be an index which is being incremented in each iteration of the Data Source Loop. Current problem is that, property expansion for data source does not use index, that is why I said convention (to access the data of source ) should be changed in order to achieve the same. These are the first thought coming to me at the moment.
Of course, there can be much better ideas to achieve the same.



Regards,
Rao.
cnanju
Occasional Contributor

Re: How to read the current executing excel row-column in a Groovy script test step?

Hi nmrao,

 

                      Thanks for elaborating the question. What you have explained above is exactly what I was looking at.

With little bit of playing around with the "SoapUI NG Pro" I could generate the script to read a particular column from the currently executing row.

 

                   Now here is my test case's steps:

  1. Groovy script Test Step: Read column from excel to property (defined in test case)
  2. Execute a Parameterized Rest request  getting value from the property
  3. Groovy script Test Step: read the response and compare that with the response/expected value in the excel column along with some business validation check using assert

I am glad that "SOAP UI Pro /Ready! API 1.9.0" has done a wonderful job of "generating the script to read data from data source for the currently executing row". Here is the steps to do that

  • Just right click on the Groovy Script Test Step editor,
  • Click On "GetData" 
  • Select the data source from where to read the data, in my case it was the added excel file's column
  • editor will ask for some meaningful parameter name, enter and click OK

That's all you are done with the Groovy script which will read the column from a data source for the currently executing row.

I guess it's one of the top features which should have been listed or added as video demo mentioning how to work with Data source.

This whole thing is my personal favorite and I call it Dynamic data driven test, as I am able to test almost anything with this approach. Many a thanks to SOAP UI Pro team for building such a wonderful feature. I am thrilled.

View solution in original post

cancel
Showing results for 
Search instead for 
Did you mean: