Forum Discussion
Thanks Justin,
The only problem with this is that MyTestName is hard coded.
Is there any way of making MyTestName a variable?
Otherwise it requires something like this....
switch ( Test_Caption )
{
case 'KeywordTests - Check_Pass':
KeywordTests.Check_Pass.Run;
break;
case 'KeywordTests - Check_Fail':
KeywordTests.Check_Fail.Run;
break;
case 'KeywordTests - Login Normal User':
KeywordTests.Login_and_verify_operator.Run();
break;
default:
Log.Warning("No test was found corresponding to :''" + Test_Caption + "''");
Hi,
eval() or evaluate() function (whatever is provided by scripting language your project is based on) might work for you.
Sample untested pseudocode:
var strTestName = 'Check_Pass';
var strTestString = 'KeywordTests.' + strTestName + '.Run();';
evaluate(strTestString);
- jr3485 years agoContributor
That's it Alex!
Thanks!!!
I knew there was a way of doing it but could not remember the function. 😅
The use case is to run random keyword functional tests from a suite of about 500.
We have daily tests that test critical functions but we'd like to add some randomness as an added confidence margin. The TestComplete random number gen seems random enough. 🙂
You have just saved me from the headache of writing and maintaining a 500+ element switch-case structure. Thanks again!