microsoft / testfx-docs

Docs for MSTest V2 test framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MSTest V2 doesn't output "TestCategory" to .TRX files (but V1 did/does)

opened this issue · comments

Hello!

Using MSTest.Framework (1.3.2) and the following code:

       [TestMethod]
        [TestCategory("Instructor chosen Grading Category Goes Here")]
        public void Basic_Fail_2()
        {
            bool correctAnswer = false;
            Assert.IsTrue(correctAnswer, "This message will be displayed when the test fails");
        }

I can run the tests from the command line to generate a .TRX / .XML file that includes the following

<TestDefinitions>
    <UnitTest name="Basic_Fail_2" storage="c:\mikesstuff\pers\dropbox\work\website\courses\bit143\lessons\lesson_03\nunit_materials\do_not_upload\mstest_using_dotnetcore\mstest_using_dotnetcore\bin\debug\netcoreapp2.0\mstest_using_dotnetcore.dll" id="468bfd94-b2bd-e0b2-dfaa-b056c00e7ae3">
      <TestCategory>
        <TestCategoryItem TestCategory="Instructor chosen Grading Category Goes Here" />
      </TestCategory>
      <Execution id="4afac95c-6b8a-4996-85d6-c8087f2e3203" />
      <TestMethod codeBase="C:\MikesStuff\Pers\Dropbox\Work\Website\Courses\BIT143\Lessons\Lesson_03\NUnit_Materials\DO_NOT_UPLOAD\MSTest_Using_DotNetCore\MSTest_Using_DotNetCore\bin\Debug\netcoreapp2.0\MSTest_Using_DotNetCore.dll" adapterTypeName="executor://mstestadapter/v2" className="MSTest_Using_DotNetCore.NUnit_Tests_Basic_Demonstrations" name="Basic_Fail_2" />
    </UnitTest>

However, when using MSTest V2 the .TRX file includes only this:

  <TestDefinitions>
   <UnitTest name="Basic_Fail_2" storage="c:\mikesstuff\pers\dropbox\work\website\courses\bit143\lessons\lesson_03\nunit_materials\do_not_upload\unittestdemo_core3_1\bin\debug\netcoreapp3.1\unittestdemo_core3_1.dll" id="daba9da9-b9e4-3614-3841-237a64d89d56">
      <Execution id="73801b0b-bd2c-4b31-ac77-2fb1e0417270" />
      <TestMethod codeBase="C:\MikesStuff\Pers\Dropbox\Work\Website\Courses\BIT143\Lessons\Lesson_03\NUnit_Materials\DO_NOT_UPLOAD\UnitTestDemo_Core3_1\bin\Debug\netcoreapp3.1\UnitTestDemo_Core3_1.dll" adapterTypeName="executor://mstestadapter/v2" className="PCE_StarterProject.NUnit_Tests_Basic_Demonstrations" name="Basic_Fail_2" />
    </UnitTest>

(Note the missing TestCategory element, and therefore the missing TestCategoryItem child element(s).)

I'd love to be able to 'tag' tests using the TestCategory attribute and have that attribute be accessible in the resulting .TRX file

Seems like a regression. Moving to the testfx repo.