Multi options application

Class library usage, coding and language questions.
swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Multi options application

Post by swmatisa » Tue Sep 13, 2011 4:22 pm

WinXP SP3 (WindowsUpdate done)
Ranorex 3.1.0
*********************************
Hello,
Could you please give me information to solve my newbie problem :
1) I have an application with 3 hardware options (Ao1 to Ao3)
2) I have a TestSuite with 3 tests cases (tc1 to tc3)
3) Ao1 must run only tc1
4) Ao2 must run only tc1 and tc2
5) Ao3 must run only tc1 and tc3
I can do a batch that execute the testSuite with tc : parameter, but it is not very funny and make me a lot of work outside Ranorex (in the real life there is more options and more test cases :( )

Is it possible to do a check at the startup (with a variable for exemple) to skip a full test case ?

Any other idea ?

Thanks for your help
SW

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Multi options application

Post by Ciege » Tue Sep 13, 2011 5:00 pm

If you use custom user code this would be pretty simple... write a launcher app that checks which machine you are on and launch the proper scripts accordingly...
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

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

Re: Multi options application

Post by Support Team » Wed Sep 14, 2011 11:41 am

Hi,

You can also create a UserCode file where you can check which Test Case you want to run and then you can deselect the ones you do not like to be executed.
.
            // get a list of all active Test Cases of the Test Suite
            IList<TestCase>testCases = TestSuite.Current.SelectedRunConfig.GetActiveTestCases();
            // iterate thru these Test Cases
            foreach (TestCase testCase in testCases)
            {
              // If you'd like to deactivate e.g. Test Case 3 you have to set the CheckState to unchecked 
              // and remove the Test Case from the list of active Test Cases
              if (testCase.Name == "TestCase3")
              {
                testCase.Checked = false;
                
              }
            }
Note that you have to activate all Test Cases within Test Suite to have them in the list of active Test Cases.

Regards,
Markus
Ranorex Support Team
.
Image

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Multi options application

Post by swmatisa » Wed Sep 14, 2011 12:08 pm

Ciege wrote:... write a launcher app that checks which machine you are on and launch the proper scripts accordingly...
Thanks Ciege, but this is the same as write a batch and it is ouside Ranorex :(
Support Team wrote:Hi,

You can also create a UserCode file where you can check which Test Case you want to run and then you can deselect the ones you do not like to be executed.
Thanks Markus. Very nice, it is exactly what I need.
SW

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Multi options application

Post by swmatisa » Tue Sep 20, 2011 3:21 pm

// ...
TestSuite.Current.SelectedRunConfig.GetActiveTestCases();
I try to find this statement in Ranorex API documentation, but I didn't found it (local and on the net).

What is the namespace and how to find more informations.

Thanks for your help.
SW

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

Re: Multi options application

Post by Support Team » Tue Sep 20, 2011 3:44 pm

swmatisa wrote:I try to find this statement in Ranorex API documentation, but I didn't found it (local and on the net).
What is the namespace and how to find more informations.
Sorry but we forgot to add the API Documentation for this Class. We will fix this issue with Ranorex 3.1.x.

The namespace of this class is
using Ranorex.Core.Testing;
Regards,
Peter
Ranorex Team
.
Image

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Multi options application

Post by swmatisa » Wed Sep 21, 2011 11:29 am

Support Team wrote:Sorry but we forgot to add the API Documentation for this Class. We will fix this issue with Ranorex 3.1.x.
Thanks for the answer. OK, I wait the new documentation.
SW

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Multi options application

Post by swmatisa » Mon Oct 10, 2011 1:10 pm

SOLUTION
Support Team wrote:You can also create a UserCode file where you can check which Test Case you want to run and then you can deselect the ones you do not like to be executed.
// get a list of all active Test Cases of the Test Suite  
IList<TestCase>testCases = TestSuite.Current.SelectedRunConfig.GetActiveTestCases();
 
It is not so easy :o

I select my test cases in the "setup" like your description, but before I must save all TestCases, to reselect all in the "teardown". Otherwise, a deselected test case is never reselected.

To solve this case, I create a class:
/// <summary>
	/// Description of TestCasesSingleton.
	/// </summary>
	public class TestCasesSingleton
	{
    	static TestCasesSingleton _Instance = null;
    	
    	static public TestCasesSingleton Instance
    	{
    		get { if (null == _Instance) {
    				_Instance = new TestCasesSingleton();
    				}
    				return _Instance; 
    		}
    	}
		
		private TestCasesSingleton()
		{
		}
	
		IList<TestCase> m_AllTestCases = null;
		public IList<TestCase> AllTestCases
		{
			get { return m_AllTestCases;}
			
			set { if (m_AllTestCases == null)
				{
					m_AllTestCases = value;
				}
			}
		}
		
		public void EnableAll()
		{
			foreach(TestCase tc in m_AllTestCases)
			{
				tc.Checked = true;
			}
		}
	}
I hope this will help somebody else.
SW