Set multiple range in user code module

Class library usage, coding and language questions.
cknopp
Posts: 8
Joined: Tue Apr 08, 2014 1:41 pm

Set multiple range in user code module

Post by cknopp » Wed Sep 17, 2014 12:49 pm

hi,

i want to set the range of a testcase in a user code module. In DataSource GUI dialog you can enter something like "1-3,5-8,10". In user code i have tried some functions mentioned in this posting "setting-datasource-range-from-and-to-parameters-from-code"

The problem is that i can only set a continuous range with the following code:

Code: Select all

TestSuite.Current.GetTestCase("TestCase").DataContext.SetRange(1,3)
If i try this code

Code: Select all

TestSuite.Current.GetTestCase("TestCase").DataContext.SetRange(DataRange.Parse("1-2,4-5"))
the following error is shown: "The specified range string contains more then one range." (Typo: than)

Update: Writing this posting i found the "DataRangeSet" class that can parse multiple ranges. So my Problem is solved :lol:

To set multiple ranges use code like this:

Code: Select all

TestSuite.Current.GetTestCase("TestCase").DataContext.SetRange(DataRangeSet.Parse("1-3,4-5,6,7-10"))
Is it correct that DataRange of the TestCase is not updated immediatly? The following code only shows the DataRange configured in the GUI:

Code: Select all

report.Log(reportlevel.Info,TestSuite.Current.GetTestCase("TestCase").DataRange.ToString)

TestSuite.Current.GetTestCase("TestCase").DataContext.SetRange(DataRangeSet.Parse("1-3,4-5,6,7-10"))

report.Log(reportlevel.Info,TestSuite.Current.GetTestCase("TestCase").DataRange.ToString)

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

Re: Set multiple range in user code module

Post by Support Team » Fri Sep 19, 2014 2:30 pm

Hi cknopp,

Please note that this is internal API, we do not recommend using it and we preserve the right to change internal methods and properties at any time. Additionally, we do not guarantee for any side effects.

Thank you for your understanding.

Regards,
Markus (S)