如何将 XUnit 事实与 TFS 中的测试用例相关联 [英] How to associate a XUnit Fact to a Test Case in TFS

查看:28
本文介绍了如何将 XUnit 事实与 TFS 中的测试用例相关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想弄清楚如何将 TFS 2018 中的测试用例与 .Net Core 项目中的 Xunit Fact 相关联.
如果我在 Visual Studio 2017 测试资源管理器中单击 XUnit Fact,关联选项将被禁用.

有谁知道如何将 Xunit Fact 与 TFS 中的测试用例关联起来?

解决方案

有一个 Rest API 可以 更新提交的工作项.

例如:

PATCH https://servername:8080/tfs/DefaultCollection/_apis/wit/workitems/[testcaseid]?api-version=1.0

内容类型:application/json-patch+json

身体:

<预><代码>[{"op": "添加","path": "/fields/Microsoft.VSTS.TCM.AutomatedTestName","value": "[namespace.classname.methodname (e.g. UnitTestProject1.UnitTest1.TestMethod2)]"},{"op": "添加","path": "/fields/Microsoft.VSTS.TCM.AutomatedTestStorage",值":[程序集名称(例如 unittestproject1.dll)"},{"op": "添加","path": "/fields/Microsoft.VSTS.TCM.AutomatedTestId","value": "[guid id]"},{"op": "添加","path": "/fields/Microsoft.VSTS.TCM.AutomatedTestType",值":单元测试"},{"op": "添加","path": "/fields/Microsoft.VSTS.TCM.AutomationStatus",价值":自动化"}]

AutomatedTestId 是一个 Guid 值,因此您可以使用此 C# 代码生成一个新的 Guid:

Guid g = Guid.NewGuid();字符串 s = g.ToString();

看看这个类似的问题我如何关联测试用例的测试方法?

I am trying to figure out how to associate a Test Case in TFS 2018 to a Xunit Fact in a .Net Core project.
If i click on the XUnit Fact in the Visual Studio 2017 Test Explorer, the association option is disabled.

Does anyone know how to associate a Xunit Fact to a Test Case in TFS?

解决方案

There is a Rest API could update work item filed.

For example:

PATCH https://servername:8080/tfs/DefaultCollection/_apis/wit/workitems/[testcaseid]?api-version=1.0

Content-Type: application/json-patch+json

Body:

[
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.TCM.AutomatedTestName",
    "value": "[namespace.classname.methodname (e.g. UnitTestProject1.UnitTest1.TestMethod2)]"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.TCM.AutomatedTestStorage",
    "value": "[assembly name(e.g. unittestproject1.dll)"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.TCM.AutomatedTestId",
    "value": "[guid id]"
  },
  {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.TCM.AutomatedTestType",
    "value": "Unit Test"
  },
   {
    "op": "add",
    "path": "/fields/Microsoft.VSTS.TCM.AutomationStatus",
    "value": "Automated"
  }
]

The AutomatedTestId is a Guid value, so you can generate a new Guid by using this C# code:

Guid g = Guid.NewGuid();
string s = g.ToString();

Take a look at this similar question How do I associate test methods to test cases?

这篇关于如何将 XUnit 事实与 TFS 中的测试用例相关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆