15 years ago
How do I control which steps are executed in SOAP UI
I am trying to create a Test Suite that will execute the following steps.
Steps:
1. Equine 1 Horse - 70% of the time
2. Equine 2 Horses - 16% of the time
3. Equine 3 Horses - 5% of the time
4. Equine 4 Horses - 3% of the time
5. Equine 5 Horses - 3% of the time
6. Equine 10 Horses - 3% of the time
I want to execute the “Equine 1 Horse” step 70 % of the time and the others at various percentages. Below is a groovy script I created, but I’m not sure it is working.
What is the best way to do something randomly select step by percentage of execution?
Groovy Script
int intRandNum;
intRandNum = Math.random();
if (intRandNum <= 69) {
// 1 horse
testRunner.runTestStepByName("Equine 1 Horse");
}
else if ((intRandNum > 69) && (intRandNumHorses <= 85)) {
// 2 horse
testRunner.runTestStepByName("Equine 2 Horses");
}
else if ((intRandNum > 85) && (intRandNumHorses <= 91)) {
// 3 horse
testRunner.runTestStepByName("Equine 3 Horses");
}
else if ((intRandNum > 91) && (intRandNumHorses <= 94)) {
// 4 horse
testRunner.runTestStepByName("Equine 4 Horses");
}
else if ((intRandNum > 94) && (intRandNumHorses <= 97)) {
// 5 hores
testRunner.runTestStepByName("Equine 5 Horses");
}
else if ((intRandNum > 97) && (intRandNumHorses <= 100)) {
// 10 horse
testRunner.runTestStepByName("Equine 10 Horses");
}
Steps:
1. Equine 1 Horse - 70% of the time
2. Equine 2 Horses - 16% of the time
3. Equine 3 Horses - 5% of the time
4. Equine 4 Horses - 3% of the time
5. Equine 5 Horses - 3% of the time
6. Equine 10 Horses - 3% of the time
I want to execute the “Equine 1 Horse” step 70 % of the time and the others at various percentages. Below is a groovy script I created, but I’m not sure it is working.
What is the best way to do something randomly select step by percentage of execution?
Groovy Script
int intRandNum;
intRandNum = Math.random();
if (intRandNum <= 69) {
// 1 horse
testRunner.runTestStepByName("Equine 1 Horse");
}
else if ((intRandNum > 69) && (intRandNumHorses <= 85)) {
// 2 horse
testRunner.runTestStepByName("Equine 2 Horses");
}
else if ((intRandNum > 85) && (intRandNumHorses <= 91)) {
// 3 horse
testRunner.runTestStepByName("Equine 3 Horses");
}
else if ((intRandNum > 91) && (intRandNumHorses <= 94)) {
// 4 horse
testRunner.runTestStepByName("Equine 4 Horses");
}
else if ((intRandNum > 94) && (intRandNumHorses <= 97)) {
// 5 hores
testRunner.runTestStepByName("Equine 5 Horses");
}
else if ((intRandNum > 97) && (intRandNumHorses <= 100)) {
// 10 horse
testRunner.runTestStepByName("Equine 10 Horses");
}