cancel
Showing results for 
Search instead for 
Did you mean: 

Data Driven Tests with variable Assertion

SOLVED
Highlighted
New Contributor

Data Driven Tests with variable Assertion

Hello,

 

I'm creating data driven tests and ran into the following scenario: For each test case, I need to test for the presence of a specific elements in a list.  The issue is that for some cases I'm looking for a single element, for others I have 2 or more elements to test.  I could seperate out test cases that have 1, 2 etc. assertions, but I'm wondering if theres a way to run all these test in a single test case.  For example, is there a way to activate an assertion if there is a value present in my data file?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
New Contributor

Re: Data Driven Tests with variable Assertion

Thanks for the reply, I think that could work but I just realized when asserting for content (Contains) if I leave the field blank in my data source, it will work (I guess testing for an empty tag?).  So for a small set it would be practicle to setup additional columns in my data source (value1, value2, value 3, etc) and have those columns populated with the required values if present.  This would avoid having to create a specific groovy script for the assertion by the testers.

 

Thanks!

View solution in original post

3 REPLIES 3
Highlighted
Community Hero

Re: Data Driven Tests with variable Assertion

Let us say, here is the data:Considering the elements that needs to be verifed.

Also assuming that the list is fixed. Say, [Value1, Value2, Value3, Value4]

Use a groovy script to make the assertions

Test, ExpectedValues

1, "Value1"

2, "Value2, Value3"

 

In the assertion, I assume you wold able to get the expected values for the respective row.

Split it by command and trim the spaces and see if those values are from the above expected list.

 

Does it sound ok?



Regards,
Rao.
Highlighted
New Contributor

Re: Data Driven Tests with variable Assertion

Thanks for the reply, I think that could work but I just realized when asserting for content (Contains) if I leave the field blank in my data source, it will work (I guess testing for an empty tag?).  So for a small set it would be practicle to setup additional columns in my data source (value1, value2, value 3, etc) and have those columns populated with the required values if present.  This would avoid having to create a specific groovy script for the assertion by the testers.

 

Thanks!

View solution in original post

Highlighted
Community Manager

Re: Data Driven Tests with variable Assertion

Happy to hear that the issue is resolvedSmiley Happy 

Thanks for sharing the solution with the Community.


Sonya Mihaljova
Community and Education Specialist

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors