Bug Report T928558
Visible to All Users

Unit Test Runner - Categories are wrongly recognized for MSTest .Net Core tests

created 4 years ago

For this code, test runner displays 'Empty category' when I use 'Category' grouping

C#
using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UnitTests { [TestClass] public class UnitTest1 { [TestMethod, TestCategory("UnitTest")] public void TestMethod1() { } [TestMethod, TestCategory("IntegrationTest")] public void TestMethod2() { } } }

If, however, I move TestCategory to attribute on its own line, CodeRush does break out to 'UnitTest' and 'IntegrationTest' categories as expected.

Comments (3)
DevExpress Support Team 4 years ago

    Hi Jonathan,

    Thank you for pointing out the issue and this code sample.

    I have reproduced the issue with displaying the Empty category, but it seems that it does not relate to in-lining attributes and is caused by collecting tests from assemblies. To make sure that I have reproduced exactly the issue you experience, please disable collecting tests from assemblies and check whether the issue persists. For this, do the following:

    1. From the Visual Studio menu, select "CodeRush\Options…" .
    2. In the tree view on the left, navigate to the "Unit Testing" folder.
    3. Select the "Test Runner" options page.
    4. Uncheck the "Collect tests from assemblies when projects are built" item.
    5. Reopen the solution.
    JH JH
    Jonathan_Halper 4 years ago

      Unchecking "Collect tests from assemblies when projects are built" does change the behavior for the better on initial solution load and still appears to be correct when I start adding a third test with its own category. However, as soon as I run the tests, they are placed back under 'Empty category'. If I then edit the test methods in any way, I see the test runner detect the category of the modified test and move it out from under 'Empty category'.

      DevExpress Support Team 4 years ago

        Thank you for the clarification.

        > However, as soon as I run the tests, they are placed back under 'Empty category'.

        This happens because tests are collected from assemblies as well. CodeRush Test Runner does that before running tests.

        We are working on a fix for this case and will inform you of our progress.

        Answers approved by DevExpress Support

        created 4 years ago

        We have addressed the issue described in this ticket and will include a fix in our next maintenance update. To apply this solution before official release, request a hotfix by clicking the appropriate version link.

        Note: Hotfixes may be unavailable for betas/updates set for release within a week.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.