Test doesn't fail when there is no data in the data source

Bug reports.
JimLin
Posts: 51
Joined: Mon Jun 02, 2014 4:23 pm

Test doesn't fail when there is no data in the data source

Post by JimLin » Thu Dec 20, 2018 3:33 pm

Hi, I have stumbled across an odd issue. Some of my tests rely on a data source which is a csv file which has a single line of data in it. If the file itself is missing, the test run fails at the very first step, which is correct.
Test fails if data source file is missing.PNG
Test fails if data source file is missing.PNG (30.11 KiB) Viewed 185 times

However, if that same file is present, but has no data in it at all, only a warning is shown instead of the test failing.
Test doesn't fail if no data in data source.PNG
Test doesn't fail if no data in data source.PNG (40.56 KiB) Viewed 185 times

Is this expected behaviour? If it is (which seems strange to me if it is), how would I get the test & test run to fail?

Edit:
I've realised that I should have added that this is Ranorex v8.2.1 and on a Windows 10 machine.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11798
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Test doesn't fail when there is no data in the data source

Post by Support Team » Fri Dec 21, 2018 9:34 am

Hello JimLin,

You could create a user code method to check if a data connector has data:
 
            var suite = (TestSuite)TestSuite.Current;

            var dataCache = suite.DataConnectorManager.GetDataCacheByConnectorName("NameOfYourConnector");

            if (dataCache.Rows.Count == 0)
            {
                throw new RanorexException("No data within data source");
            }

Note: The code needs to be executed before your test case, since a test case with an empty data connector is simply skipped

Sincerely,
Robert
.
Image

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4550
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Test doesn't fail when there is no data in the data source

Post by odklizec » Fri Dec 21, 2018 10:02 am

Hi Robert,

Although it's nice to learn about an option to check the data source availability, I think that the test should definitely fail by itself, if there is no data source availability code implemented? I too was confused by the fact that the test stated Success, even though the data were missing ;)
Last edited by odklizec on Thu Dec 27, 2018 10:13 am, edited 1 time in total.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

JimLin
Posts: 51
Joined: Mon Jun 02, 2014 4:23 pm

Re: Test doesn't fail when there is no data in the data source

Post by JimLin » Fri Dec 21, 2018 10:25 am

Hi odklizec and Robert,

Thank you for your replies.

I will raise a post in the bug report section of the forum and look at implementing the work round.

Have a good xmas.

Cheers James

JimLin
Posts: 51
Joined: Mon Jun 02, 2014 4:23 pm

Re: Test doesn't fail when there is no data in the data source

Post by JimLin » Fri Dec 21, 2018 10:52 am

Actually Robert, please could you move this to the bug forum for me, as it would be better than me duplicating it.

Cheers,
James

User avatar
Support Team
Site Admin
Site Admin
Posts: 11798
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Test doesn't fail when there is no data in the data source

Post by Support Team » Thu Dec 27, 2018 10:15 am

Hello James,

I moved the topic to "Bug Reports" and added an issue in our bug tracking system.

Thank you!

Regards,
Bernhard
.
Image

JimLin
Posts: 51
Joined: Mon Jun 02, 2014 4:23 pm

Re: Test doesn't fail when there is no data in the data source

Post by JimLin » Wed Jan 02, 2019 12:24 pm

Hi Robert, Bernhard,

Following the xmas break, I have finally implemented the workaround. Unfortunately, although the code throws an error for the module failing, as can be seen below, the test case/test suite still doesn't fail and shows as 'Success'.
No data code doesnt force test suite to fail.png
No data code doesnt force test suite to fail.png (360.39 KiB) Viewed 115 times
Regards,
James

User avatar
Support Team
Site Admin
Site Admin
Posts: 11798
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Test doesn't fail when there is no data in the data source

Post by Support Team » Fri Jan 04, 2019 1:54 pm

Hello James,

Happy new year!
I'm afraid this doesn't work in the setup region of the test suite. In order to get an error in the pie chart, you would have to slightly change the structure of your test case. You will need a test case that fails to get the error in the report. You can add smart folders as a workaround.

FailingReport.png
FailingReport.png (7.77 KiB) Viewed 96 times
Sincerely,
Bernhard
.
Image