Stop if no rows available

Ask general questions here.
byonush
Posts: 7
Joined: Mon Mar 12, 2012 3:53 pm

Stop if no rows available

Post by byonush » Wed Jun 20, 2012 4:46 pm

I have a step in my test suite that calls a stored procedure and uses some parameters. Everything works just fine most of the time. The problem I am having is sometimes the data has not populated yet and the test suite will show as passed and a message saying:

Warning: The data source is valid but contains zero data rows

After that it will proceed on. How can I make it so if no data rows are found then it will stop the test suite?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Stop if no rows available

Post by Support Team » Thu Jun 21, 2012 3:11 pm

Hi,
byonush wrote:How can I make it so if no data rows are found then it will stop the test suite?
You can perform this, by adding a test case after the data-driven test case.
In this test case add a user code module, or a recording mit a user code action.

Add the following user code to the user code module/action:
if (TestSuite.Current.GetTestCase("<TestCase>").DataContext.Source.Rows.Count <= 0)
    Report.Failure("No Data Rows in Data Source");
whereas <TestCase> is the name of the data driven test case.


Regards,
Tobias
Ranorex Team