我需要根据2个枚举的结果创建测试用例。 例如:基于2枚举的多个permuations
public enum Test_ID
{
// for ram test
test1 = 1,
test2 ,
test3 ,
// for video test
test4 ,
test5 ,
// many more...
}
public enum Test_Result
{
NOT_FAIL = 0,
FAIL
}
public struct ResultStruct
{
public Test_ID id;
public Test_Result res;
}
与其他一些类结果的是依赖于这两个枚举。
public class foo
{
public ResultStruct[] ResStructArr = new ResultStruct[MAX_NUM_OF_TESTS];
public void updateTestsResults()
{
getResult();
for (int i = 0; i <= MAX_NUM_OF_TESTS; i++)
{
if(ResStructArr[i].id == 1 && ResStructArr[i].res == FAIL ||
ResStructArr[i].id == 2 && ResStructArr[i].res == FAIL ||
ResStructArr[i].id == 3 && ResStructArr[i].res == FAIL)
{
ramtest.result = FAIL;
}
else
{
ramtest.result = NOT_FAIL;
}
// Update other tests results here
}
}
public void getResult()
{
// get Test_ID and Test_Result and put it in struct array
}
// Perform tests..(Ram Test, Video tests, etc)
}
但是对于我的测试用例,我必须测试2个枚举的所有组合。 喜欢:
对于RAM: 测试用例1:
_testId = 1,_testRes = NOT_FAIL
_testId = 2,_testRes = NOT_FAIL
_testId = 3,_testRes = NOT_FAIL
测试案例2:
_testId = 1,_testRes = NOT_FAIL
_testId = 2,_testRes = FAIL
_testId = 3,_testRes = NOT_FAIL
测试用例3:
_testId = 1,_testRes = NOT_FAIL
_testId = 2,_testRes = FAIL
_testId = 3,_testRes = FAIL
测试用例4:
_testId = 1,_testRes = FAIL
_testId = 2,_testRes = NOT_FAIL
_testId = 3,_testRes = FAIL
等等...
对于视频: 测试用例1:
_testId = 4,_testRes = FAIL
_testId = 5,_test RES = FAIL
测试用例2:
_testId = 4,_testRes = PASS
_testId = 5,_testRes = FAIL
测试用例3:
_testId = 4,_testRes = FAIL
_testId = 5,_testRes = PASS
等等...
我读here,我可以得到2枚枚举的所有排列组合。但不是我想要的。
有没有办法做到这一点,或者我必须一个一个地手动编写测试用例?
编辑:
我已经编辑我的问题,这样它会更清楚我想做的事情。
我想创建测试用例,就像我上面描述的一样。在William Custode的帮助下,我能够获得枚举的所有排列组合。但我坚持创建测试用例。
除了所有排列之外,您还想要什么? –
对我来说,这些不是测试用例,而是结果组合。 –
当我假设你不想要所有的排列,但只有某些排列时,我是对的吗?就像你不希望任何组合的测试结果不同'组'(testID = 1 testRES = OK和testID = 4 testRES = Fail会是一个无效组合)?我认为这很容易实现。只要让我知道,如果这是你需要的。 –