代码之家  ›  专栏  ›  技术社区  ›  Bittercoder

如何通过OTA API从质量中心的测试中删除一个步骤

  •  1
  • Bittercoder  · 技术社区  · 14 年前

    在质量中心OTA API中,如何从测试中删除步骤。当我使用DesignStepFactory的removeetem方法删除步骤时,它们仍然保留-我已尝试通过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文档

    移除方法

    描述:从 数据库。移除发生 立即,没有职位。

    语法:

    项目键:

    这个步骤ID(长),指 步骤对象或变量数组 步骤.IDs.Step.身份证。

    所以看起来应该有用。仅供参考,这是QC10的。

    1 回复  |  直到 13 年前
        1
  •  0
  •   Bittercoder    14 年前

    修复方法是使用List(“”)来检索步骤列表,在工厂中使用索引访问器会返回无效的步骤实例,其中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.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);