xUnit测试的TestCategory属性不会最终出现在TFS 2015.2的TRX文件中 [英] TestCategory attributes of xUnit tests do not end up in TRX file on TFS 2015.2

查看:66
本文介绍了xUnit测试的TestCategory属性不会最终出现在TFS 2015.2的TRX文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我尝试实现以下目标:在测试方法上,我想指定反映例如TFS上的测试用例编号,此单元测试是实施".然后当我跑步时 在TFS上执行测试,我希望.TRX文件将这些指定的特征反映为TestCategory元素,以便能够在VS测试结果或TFS上显示此列.但是,这些属性不会转换/映射到TRX文件.

当我在测试中进行MSTest单元测试时,TestCategory属性将映射到TRX结果文件中,以后可以显示如下:

在TRX文件中,可以在XML的部分中找到相应的部分.


在ALM博客上阅读以下文章后,我实际上认为xUnit Trait属性已映射到MSTest的TestCategory属性,然后也可以使用在TRX文件中.

请参阅:

看来,这没有完成.我检查了xUnit测试适配器的一些代码,但没有找到任何东西,这会将特征映射到测试类别项.

我已经尝试了名称为"TestCategory","Category","Trait"等的特征.

我在github上打开了一个新的xUnit问题,但由于xUnit Test Adapter似乎在正确的事情.参见 https://github.com/xunit/xunit/issues/1052 

有人可以向我解释一下,这是怎么回事?

感谢您的帮助!

最好的问候,

Harald

解决方案

Harald ,

阅读您的描述后,这是我的看法:

首先,我无法使用mstest或vstest.console来运行xUnit测试方法,请与我分享您的命令.我只能使用xunit.console来运行xUnit测试方法,只需链接以下命令行即可:

xunit.console"C:\ Users \ Administrator \ Documents \ Visual Studio 2015 \ Projects \ UnitTestProject1 \ UnitTestProject1 \ bin \ Debug \ UnitTestProject1.dll"

>>我已经尝试了名称为"TestCategory","Category","Trait"等的特征.

如果要在trx文件中查看TestCategory属性,请参考以下步骤:

1).像下面的代码一样,在TestMethod之前添加TestCategory属性:

 [TestMethod]
        [TestCategory("123"))
        公共无效TestMethod1()
        {


        } 

2).然后使用Mstest像以下命令一样运行此测试:

 mstest/testcontainer:UnitTestProject1.dll/category:"123" 

3).然后在VS中打开trx文件,我们可以看到testcategory属性,请参考以下屏幕截图:

但是如何用xunit.console来实现呢?

如果我误解了您的问题,请随时告诉我.如果您可以在VS中实现它,那么TFS也可以.

此致

奥斯卡


Hello,

I try to achieve something like the following: on test methods, I would like to specify traits, which reflect e.g. the test-case number on TFS, which this unit test is "implementing". When I then run and execute the tests on TFS, I would like to have the .TRX file reflecting these specified traits as TestCategory elements, to be able to display this column in VS test results or on TFS. However, these attributes are not transformed/mapped to the TRX file.

When I have MSTest unit tests in my tests, the TestCategory attribute becomes mapped into the TRX result file and later on can be displayed like the following:

In the TRX file, the corresponding section can be found in the section of the XML.


After reading the following post on the ALM blog, I actually assumed, that the xUnit Trait attribute becomes mapped to the TestCategory attribute of MSTest and then is also available in the TRX file.

See: https://blogs.msdn.microsoft.com/visualstudioalm/2013/06/11/part-3-unit-testing-with-traits-and-code-coverage-in-visual-studio-2012-using-the-tfs-build-and-the-new-nuget-adapter-approach/


As it seems, this is not done. I checked some of the code of the test adapter of xUnit, but have not found anything, which would map the trait to a test-category item. 

I already tried traits with the name: "TestCategory", "Category", "Trait", etc.

I opened a new xUnit issue on github, but got redirected to the TFS community, as the xUnit Test Adapter seems to do the right things. See https://github.com/xunit/xunit/issues/1052 

Can somebody probably explain to me, what is happening here?

Thanks for any help regarding this!

Best regards,

Harald

解决方案

Hi Harald,

After reading your description, here is my opinion:

First, I could not use mstest or vstest.console to run the xUnit test method in my side, please share me you command. I could only use xunit.console to run the xUnit test method, just link this command line:

xunit.console "C:\Users\Administrator\Documents\Visual Studio 2015\Projects\UnitTestProject1\UnitTestProject1\bin\Debug\UnitTestProject1.dll"

>>I already tried traits with the name: "TestCategory", "Category", "Trait", etc.

If you want to see TestCategory property in trx file, please refer to the following step:

1). Add TestCategory attribute before TestMethod, just like the following code:

        [TestMethod]
        [TestCategory("123")]
        public void TestMethod1()
        {


        }

2). Then with Mstest to run this test like the following command:

mstest /testcontainer:UnitTestProject1.dll /category:"123"

3). Then open trx file in VS, we could see the testcategory property, please refer to the following screenshot:

But how to implement it with xunit.console?

If I misunderstand your issue, please feel free to let me know. If you could implement it in VS, and TFS could be able too.

Sincerely,

Oscar


这篇关于xUnit测试的TestCategory属性不会最终出现在TFS 2015.2的TRX文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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