在Quality Center OTA API中,如何删除测试中的步骤。当我使用DesignStepFactory的RemoveItem方法删除步骤时,它们仍然存在 - 我尝试通过ID和步骤引用进行删除:
Test test = _qcAccess.AddTest(folderId);
test.Name = "Test 1";
test.Post();
DesignStepFactory factory = (DesignStepFactory) test.DesignStepFactory;
DesignStep step = (DesignStep)factory.AddItem(1);
step.StepName = "Step1";
step.Post();
Test test2 = _qcAccess.FindExistingTest((int)test.ID);
DesignStepFactory factory2 = (DesignStepFactory) test2.DesignStepFactory;
Assert.Equal(1, test2.DesStepsNum);
factory2.RemoveItem(factory2[0]);
test2.Post();
Test test3= _qcAccess.FindExistingTest((int)test.ID);
Assert.Equal(0, test3.DesStepsNum); // test fails here, DesStepsNumb is still 1
根据OTA API文档
RemoveItem方法
描述:从中删除项目 数据库。去除发生 马上,没有邮政。
语法:
Public Sub RemoveItem(ByVal ItemKey As Variant)
的ItemKey:
Step.ID(长),对。的引用 Step Object或Variant数组 Step.IDs.Step.IDs。
所以它看起来应该有效。仅供参考,这是针对QC10的。
有什么想法吗?
答案 0 :(得分:0)
修复是使用List(“”)来检索步骤列表,它使用工厂上的索引访问器显示返回无效的步骤实例,其中ID只是元素的索引,并且所有属性都为null
Test test = _qcAccess.AddTest(folderId);
test.Name = "Test 1";
test.Post();
DesignStepFactory factory = (DesignStepFactory) test.DesignStepFactory;
DesignStep step = (DesignStep)factory.AddItem(1);
step.StepName = "Step1";
step.Post();
test.Post();
Test test2 = _qcAccess.FindExistingTest((int)test.ID);
DesignStepFactory factory2 = (DesignStepFactory)test2.DesignStepFactory;
Assert.Equal(1, test2.DesStepsNum);
var list = factory2.NewList(""); // get a list
factory2.RemoveItem(list[1]); // note: list indexing starts at 1 (ugh!)
test2.Post();
Test test3 = _qcAccess.FindExistingTest((int)test.ID);
Assert.Equal(0, test3.DesStepsNum);