GetActiveTestContainers returns 0 Entries

Bug reports.
thiede
Posts: 18
Joined: Thu Oct 27, 2016 12:13 pm

GetActiveTestContainers returns 0 Entries

Post by thiede » Tue Apr 04, 2017 10:11 am

Hi,

I'm using Ranorex 7 and try to get all TestCases using:

Code: Select all

TestSuite.Current.SelectedRunConfig.GetActiveTestContainers()
But it returns a list with 0 entries.
Is there a missing implementation?

Best Regards Christopher

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

Re: GetActiveTestContainers returns 0 Entries

Post by Support Team » Wed Apr 05, 2017 12:34 pm

Hello Christopher,

Unfortunately this seems to be a bug in the latest version of Ranorex. Thank you for reporting it. I have entered the bug to our internal bug tracking system.

Currently, we do not know when this issue will be fixed. This depends on various factors. Nevertheless, all reported bugs and feature requests are documented in the release notes, with every new version release of Ranorex.

Thank you for your understanding.

Sincerely,
Tomaž
.
Image

bovenr
Posts: 2
Joined: Wed Apr 12, 2017 7:53 am

Re: GetActiveTestContainers returns 0 Entries

Post by bovenr » Wed Apr 12, 2017 7:55 am

Hi,

We just updated from 5.3 to 7.0 and use this code to generate custom reporting.

Is there an alternative method that can be used to get all testcases in the testsuite?

With kind regards,

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: GetActiveTestContainers returns 0 Entries

Post by McTurtle » Thu Apr 13, 2017 4:23 pm

Hello bovenr,

I am sure they will fix this bug soon. But meanwhile you can use the code that we use as workaround at our company:
private IList<TestCaseNode> GetActiveTestCases()
        {
            var suite = (TestSuite)TestSuite.Current;          
            IList<TestCaseNode> sample_list=new List<TestCaseNode>{};           
            var entries = suite.GetAllTestSuiteEntries();

            foreach (var entry in entries)
            {
                var tc = entry as TestCaseNode;
                if (tc != null)
                {
                    if (tc.Checked && !tc.IsRootTestCase && !tc.IsSmartFolder)
                    {
                        sample_list.Add(tc);                
                    }
                }
            }
            return sample_list;
        }
Make sure to check the release notes when the next release comes around and see if it is already fixed so you don't continue using a workaround instead of the intended method.

I hope this helps.

Regards,
McTurtle

bovenr
Posts: 2
Joined: Wed Apr 12, 2017 7:53 am

Re: GetActiveTestContainers returns 0 Entries

Post by bovenr » Wed Apr 19, 2017 7:07 am

Works perfectly.

Thank you.

thiede
Posts: 18
Joined: Thu Oct 27, 2016 12:13 pm

Re: GetActiveTestContainers returns 0 Entries

Post by thiede » Mon Jul 31, 2017 12:29 pm

Hi,

I updated to Ranorex 7.1 and tried it with "Run selected Smart Folder". I have 20 Test Cases in this Test Suite but only 4 in the Smart Folder. If I call TestSuite.Current.SelectedRunConfig.GetActiveTestContainers() I get all 20 but I expected 4 because the Smart Folder is my SelectedRunConfig isn't it?

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: GetActiveTestContainers returns 0 Entries

Post by McTurtle » Tue Aug 01, 2017 1:42 pm

Hello thiede,

I have tested it and it seems to be fixed.
The below example works:
private IList<TestCaseNode> SelectedRunConfig_GetActiveTestContainers()
		{
			var suite = (TestSuite)TestSuite.Current;
			IList<TestCaseNode> sample_list=new List<TestCaseNode>{};
			var entries = suite.SelectedRunConfig.GetActiveTestContainers();
			
			foreach (var entry in entries)
			{
				var tc = entry as TestCaseNode;
				if (tc != null)
				{
					if (!tc.IsRootTestCase && tc.IsSmartFolder)
					{
						sample_list.Add(tc);
					}
				}
			}
			return sample_list;
		}
There needs to be a check for the container to actually be a smart folder ("tc.IsSmartFolder").

The run config is what test cases and smart folders you have "checked" in your test suite. In this case the run config is 3 test cases and 2 smart folders...
Ranorex Studio.png
Ranorex Studio.png (16.84 KiB) Viewed 593 times
Can you post your implementation and together we might eliminate the issue :)

Regards,
McTurtle