我需要帮助。我必须从excel创建测试用例,格式如下:
**Current NextState Function Type**
GREETING-1,repeat,PMSG
REPEAT,CallerType,PMSG
CALLERTYPE,XferBridges(DTMF:1),ClaimMenu(DTMF:2),XferLine2(DTMF:3),XferLine2(DTMF:4),Menu
CLAIMMENU,RejectMenu(DTMF:1),XferLine2(DTMF:2),Menu
REJECTMENU,NotCovered(DTMF:1),Terminated(DTMF:2),NMCard(DTMF:3),NMGroup(DTMF:4),Refill(DTMF:5),NoDrugNDC(DTMF:6),XferLine2(DTMF:2),Menu
NOTCOVERED,RejectMenu(DTMF:1),Menu
TERMINATED,XferLine2(DTMF:1),Menu
NMCARD,XferLine2(DTMF:1),Menu
NMGROUP,XferLine2(DTMF:1),Menu
REFILL,XferLine2(DTMF:1),Menu
NODRUGNDC,XferLine2(DTMF:1),Menu
XFERBRIDGES,STOP,PMSG
XFERLINE2,STOP,PMSG
THANKYOU,GoodBye,PMSG
GOODBYE,STOP,PMSG
该工具将生成n个测试用例。请指导我将编写哪些代码可以生成以下类型的测试用例:
Case 1: Greeting-1 -> Repeat -> CallerType, Press DTMF 1 ->XferBridges ->STOP
Case 2: Greeting-1 -> Repeat -> CallerType, Press DTMF 2 ->ClaimMenu, Press DTMF 1 -> RejectMenu, Press DTMF 1 ->NotCovered, Press DTMF1 -> RejectMenu -> STOP( from entering infinte into loop)
Case 3: Greeting-1 -> Repeat -> CallerType, Press DTMF 2 ->ClaimMenu, Press DTMF 1 -> RejectMenu, Press DTMF 2 -> Terminated, Press DTMF 1 ->XferLine2 ->STOP
Case 4: Greeting-1 -> Repeat -> CallerType, Press DTMF 2 ->ClaimMenu, Press DTMF 1 -> RejectMenu, Press DTMF 3 -> NMCard, Press DTMF 1 ->XferLine2 ->STOP
**.**
**.**
等等
你可能已经知道我在这里做了什么。尝试为每个调用流创建测试用例,如果下一个状态是PMSG然后将其添加到同一个数组,但是如果下一个状态是MENU则创建新数组(这意味着新的测试用例)将通过所有DTMF选项及其相应的下一个状态等等
我使用递归循环来获取输出,但是它给出了错误的值。
代码:
function generateTestCaseList(nextState) {
var incCount = 1;
var positionInt = findNextState(nextState);
var tempStoredArray = allState[positionInt];
if(tempStoredArray[0].toLowerCase() == menuName.toLowerCase())
{
incCount = menuPostion;
f = true;
}
else if(tempStoredArray[0].toLowerCase() == nextMenuName.toLowerCase())
incCount = nextMenuPostion;
var tempStr = getState(tempStoredArray, incCount);
var tempArr = tempStr.toLowerCase().split("%");
nextState = tempArr[1];
parentStr = parentStr + tempArr[0];
var cntInfi = parentStr.toLowerCase().split(nextState).length -1;
if(cntInfi == 2)
{
return parentStr;
}
else if(nextState != "stop")
{
var pstInt = findNextState(nextState);
var tempArr = allState[pstInt];
if(tempArr[tempArr.length -1] == "Menu" && f == true)
{
nextMenuName = tempArr[0];
var tempMenuPsx= tempArr.length - 2;
//WScript.Echo("tempMenuPsx"+nextMenuName+tempMenuPsx);
for(var k=tempMenuPsx;k >0 ;k--)
{
nextMenuPostion = k;
//WScript.Echo("nextMenuPostion"+nextMenuPostion);
WScript.Echo("parentStr"+parentStr);
var temp = generateTestCaseList(nextState);
childStr = childStr +temp;
resultList.push(childStr);
childStr = "";
}
}
else
{
generateTestCaseList(nextState);
}
}
else
{
return parentStr;
}
}
function findNextState(nextState) {
for(var l=0;l<allState.length;l++)
{
if(allState[l][0].toLowerCase()==nextState.toLowerCase())
return l;
}
return 0;
}
function getState(tempArray,l) {
var tempStr = tempArray[0];
if(tempArray[2] =="GETV")
tempStr = tempStr +";Voice: Say Something;"+tempArray[2]+";$%"+tempArray[1];
else if(tempArray[2] =="PMSG")
tempStr = tempStr +";"+tempArray[2]+";$%"+tempArray[1];
else
tempStr = tempStr +";DTMF:"+l+";"+tempArray[tempArray.length -1]+";$%"+tempArray[l];
return tempStr;
}
结果(“$”是此处的下一个状态分隔符):
1. greeting-1;pmsg;$repeat;pmsg;$callertype;dtmf:4;menu;$xferline2;pmsg;$
2. greeting-1;pmsg;$repeat;pmsg;$callertype;dtmf:3;menu;$xferline2;pmsg;$
3. greeting-1;pmsg;$repeat;pmsg;$callertype;dtmf:2;menu;$claimmenu;dtmf:2;menu;$xferline2;pmsg;$claimmenu;dtmf:1;menu;$rejectmenu;dtmf:7;menu;$xferline2;pmsg;$rejectmenu;dtmf:6;menu;$nodrugndc;dtmf:1;menu;$
4. greeting-1;pmsg;$repeat;pmsg;$callertype;dtmf:2;menu;$claimmenu;dtmf:2;menu;$xferline2;pmsg;$claimmenu;dtmf:1;menu;$rejectmenu;dtmf:7;menu;$xferline2;pmsg;$rejectmenu;dtmf:6;menu;$nodrugndc;dtmf:1;menu;$rejectmenu;dtmf:1;menu;$notcovered;dtmf:1;menu;$rejectmenu;dtmf:7;menu;$
5. greeting-1;pmsg;$repeat;pmsg;$callertype;dtmf:2;menu;$claimmenu;dtmf:2;menu;$xferline2;pmsg;$claimmenu;dtmf:1;menu;$rejectmenu;dtmf:7;menu;$xferline2;pmsg;$rejectmenu;dtmf:6;menu;$nodrugndc;dtmf:1;menu;$rejectmenu;dtmf:1;menu;$notcovered;dtmf:1;menu;$rejectmenu;dtmf:7;menu;$rejectmenu;dtmf:6;menu;$nodrugndc;dtmf:1;menu;$
输出包含单个呼叫流程中的所有DTMF选项。 任何输入都会有很大的帮助。
答案 0 :(得分:0)
我已经得到了解决方案,它效率不高但确实提供了所需的输出。
function generateTestPlan() {
var menuCount = 0;
for(var g=0;g<allState.length;g++)
{
var tempArr = allState[g];
if(tempArr[tempArr.length-1] == "Menu")
{
var tempArr = [];
tempArr.push(allState[g][0]);
for(var i =1;i<allState[g].length-1; i++)
{
tempArr.push(allState[g][i]);
menuCount++;
}
menuList.push(tempArr);
}
}
var firstState = allState[0][0];
for(var k=0;k < menuCount*1000;k++)
{
getCallFlow(firstState,stack1)
stack.push(stack1);
stack1 = [];
}
stack = eliminateDuplicates(stack);
}
function getCallFlow (nextState,stack1)
{
var positionInt = findNextState(nextState);
var tempStoredArray = allState[positionInt];
var g = 0;
for(var b= 0; b < menuList.length ;b++)
{
if(menuList[b][0] == tempStoredArray[0])
{
var len = menuList[b].length -1;
g =Math.floor(Math.random() * len) + 1 ;
}
}
var tempStr = getState(tempStoredArray,g);
var tempArr = tempStr.toLowerCase().split("%");
var nextState1 = "";
var multipleGoto = tempArr[1].toLowerCase().split("@").length -1;
if(multipleGoto > 1)
{
var multipleArray = tempArr[1].toLowerCase().split("@");
//WScript.Echo(multipleArray)
var len = multipleArray.length -1;
var choose =Math.floor(Math.random() * len) + 1 ;
//WScript.Echo(choose)
nextState1 = multipleArray[choose];
//WScript.Echo(nextState1)
}
else
{
nextState1 = tempArr[1];
}
stack1.push(tempArr[0]);
if(checkIfArrayIsUnique(stack1) == false)
{
stack1.push("stop");
return ;
}
if(nextState1 == "stop")
{
stack1.push("stop");
return ;
}
else
{
getCallFlow(nextState1,stack1);
}
}
function findNextState(nextState) {
for(var l=0;l<allState.length;l++)
{
if(allState[l][0].toLowerCase()==nextState.toLowerCase())
return l;
}
return 0;
}
&#13;