如何通过 OTA API 从 Quality Center 中的测试中删除步骤

发布于 2024-09-26 08:02:04 字数 1074 浏览 0 评论 0原文

在 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(ByVal ItemKey作为变体)

项目键:

Step.ID(长),对 步骤对象或变体数组 步骤.ID.步骤.ID。

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

有什么想法吗?

In the Quality Center OTA API how can you delete steps from a test. When I delete steps using the RemoveItem method of the DesignStepFactory, they still remain - I've tried deleting by both ID and step reference:

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 

According to the OTA API documentation

RemoveItem Method

Description: Removes item from the
database. Removal takes place
immediately, without a Post.

Syntax:

Public Sub RemoveItem(ByVal ItemKey As Variant)

ItemKey:

The Step.ID (long), a reference to the
Step Object or a Variant array of
Step.IDs.Step.IDs.

So it looks like it should work. FYI this is for QC10.

Any thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲欢浪云 2024-10-03 08:02:04

修复方法是使用 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);

The fix is to use List("") to retrieve the list of steps, it appears using the indexed accessor on the factory returns invalid step instances, where the ID is just the index of the element, and all properties are 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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文