Randomized data generation for parameters.
-
Tuesday, July 24, 2012 3:22 PM
Hello all,
I have an rule like
DoSomething(int n)
{
if (n>10)
goto state A
else goto state B
}
I want to assign value for n in such a way that every time the rule is invoked, it randomly assigns a value to n.
Is there any way to do it?
- Edited by Vivek.Vishal Tuesday, July 24, 2012 3:22 PM
All Replies
-
Tuesday, July 24, 2012 5:22 PM
It appears there is a Choice class in Spec Explorer to randomly choose a value from a set of values/ranges.
Another possibility:
Condition.IsTrue(n>0) - for letting the Spec Explorer choose a positive random value, for example.
Hope it helps.
Dharma
-
Wednesday, July 25, 2012 8:28 AM
Hello Dharma,
Thanks for your reply. One of the requirements of my testing is to test a rule with different random assignment of parameters (satisfying some condition). However, every time I get the same random value of parameters (satisfying the conditions) for my rule.
Thanks,
Vivek
-
Wednesday, July 25, 2012 12:07 PM
I saw "random" discussions here: http://appmbt.blogspot.com/2012/05/modeling-stochastic-systems-in-spec.html
- Marked As Answer by Vivek.Vishal Sunday, July 29, 2012 9:26 AM
-
Sunday, July 29, 2012 9:26 AM
Finally found the solution, Thanks Dharma,
Somthing like following solves the problem,
DoSomething(int n)
{
Combination.Strategy(CombinationStrategy.Coverage);
Condition.IsTrue(appStatus == States.ABC);
if (n > 10)
{
Condition.IsTrue(i == random.Next(11,100));
appStatus = States.A;
}
else
{
Condition.IsTrue(i == random.Next(-100, 10));
appStatus = States.B;
}
}- Marked As Answer by Vivek.Vishal Sunday, July 29, 2012 9:26 AM

