locked
Filter by /category with mstest.exe and VS2017 RRS feed

  • Question

  • Edit: This is a Visual Studio 2017 issue. Repeated the same procedure with VS2015 and all works as itended.

    I have created a simple unit test project in VS2017 with two unit tests. These tests are marked with the category "Ores" as shwon below:

    [TestClass]
    public class Copper
    {
        [TestCategory("Ores"), TestMethod]
        public void CheckCopper()
        {
            DataMiner locMiner = new DataMiner();
    
            string result = locMiner.GetCopper();
    
            Assert.AreEqual("Copper", result);
        }
    }

    Now i try to run this test with mstest.exe via commandline with the /category filter. The complete call is: mstest /testcontainer:TestSystem.dll /category:Ores

    MSTest.exe is linked through the Path variable: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE;"

    I get the "No test to execute" message. It doesnt matter if i write the category as "Ores" or Ores. Without the /category filter, mit test are run as intended.

    In the absence of a verified account, unfortunately only the description:

    Failed testrun with category.
    C:\Users\Staab\Documents\Visual Studio 2017\Projects\KategoryUnitTest\TestSystem\bin\Debug>mstest /testcontainer:TestSystem.dll /category:Ores

    Microsoft (R) Test Execution-Befehlszeilentool Version 15.0.26621.2
    Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.

    TestSystem.dll wird geladen...
    Ausführung wird gestartet...
    Es sind keine Tests zum Ausführen vorhanden.

    No problems without category.
    C:\Users\Staab\Documents\Visual Studio 2017\Projects\KategoryUnitTest\TestSystem\bin\Debug>mstest /testcontainer:TestSystem.dll

    Microsoft (R) Test Execution-Befehlszeilentool Version 15.0.26621.2
    Copyright (c) Microsoft Corporation. Alle Rechte vorbehalten.

    TestSystem.dll wird geladen...
    Ausführung wird gestartet...

    Ergebnisse                          Tests der obersten Ebene
    ----------                          ------------------------
    Erfolgreich                         TestSystem.Copper.CheckCopper
    Erfolgreich                         TestSystem.Iron.CheckIron
    2/2 Test(s) Erfolgreich

    Zusammenfassung
    ---------------
    Testlauf "Abgeschlossen".
      Erfolgreich  2
      --------------
      Gesamt       2
    Ergebnisdatei:     C:\Users\Staab\Documents\Visual Studio 2017\Projects\KategoryUnitTest\TestSystem\bin\Debug\TestResult
    s\Staab_LAPTOP-STAAB 2017-09-20 11_20_29.trx
    Testeinstellungen: Standardtesteinstellungen



    • Edited by deBloB90 Wednesday, September 20, 2017 10:29 AM
    Wednesday, September 20, 2017 9:21 AM

Answers

  • Hi deBloB90,

    Thank you posting in MSND forum.

    Based on your description, I test in my side. And I get the same error as yours in VS2017.

    I think this is really limitation of assemblies in VS2017.

    Please go to Help -> Send feedback -> report a problem to report this to the VS developing team directly.

    In addition, here's a temporary workaround, you could have a try refer to steps below.

    Please remove assemblies “Microsoft.VisualStudio.TestPlatform.TestFramework” and “Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions”, and add assembly “Microsoft.VisualStudio.QualityTools.UnitTestFramework” in VS2017, then execute test with command below:

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\MSTest.exe" /testcontainer:TestSystem.dll /category:"Ores"

    Thanks for your understanding.

      

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Thursday, September 21, 2017 4:25 AM
    • Marked as answer by deBloB90 Thursday, September 21, 2017 8:10 AM
    Thursday, September 21, 2017 4:25 AM

All replies

  • Hi deBloB90,

    Thank you posting in MSND forum.

    Based on your description, I test in my side. And I get the same error as yours in VS2017.

    I think this is really limitation of assemblies in VS2017.

    Please go to Help -> Send feedback -> report a problem to report this to the VS developing team directly.

    In addition, here's a temporary workaround, you could have a try refer to steps below.

    Please remove assemblies “Microsoft.VisualStudio.TestPlatform.TestFramework” and “Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions”, and add assembly “Microsoft.VisualStudio.QualityTools.UnitTestFramework” in VS2017, then execute test with command below:

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\MSTest.exe" /testcontainer:TestSystem.dll /category:"Ores"

    Thanks for your understanding.

      

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Thursday, September 21, 2017 4:25 AM
    • Marked as answer by deBloB90 Thursday, September 21, 2017 8:10 AM
    Thursday, September 21, 2017 4:25 AM
  • Dear friend,

    If my reply could resolve you issue or doubt, please help to mark it as answer if it's okay for you.

    Thanks for your understanding and cooperation.

     

    Best regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Thursday, September 21, 2017 7:45 AM
    Thursday, September 21, 2017 7:45 AM
  • Thanks Fletcher! Your workaround "solves" the problem.
    This action is a downgrade to MSTestV1, right?

    A ticket via VS2017 and an issue report on GitHub is raised.

    Looking forward to execute an command line based unit test with MSTestV2 and VS2017...

    FYI:
    https://github.com/Microsoft/testfx/issues/272
    https://developercommunity.visualstudio.com/content/problem/116381/filter-by-category-with-mstestexe-and-vs2017.html

    As mentioned in the github thread, i cant find the documentation for MSTestV2 VS2017 command line unit test execution. Can you give me a hint for this?

    Thursday, September 21, 2017 9:03 AM
  • Dear friend,

    Thanks for your response.

    >> This action is a downgrade to MSTestV1, right?It's not called MSTestV1, we just call it MSTest. MSTest has been released as a new NuGet package solution that is no longer tightly coupled to the Visual Studio version. You could refer to following blog for more details:

    https://blogs.msdn.microsoft.com/devops/2016/06/17/taking-the-mstest-framework-forward-with-mstest-v2/

    >> As mentioned in the github thread, i cant find the documentation for MSTestV2 VS2017 command line unit test execution. Can you give me a hint for this?

    I cannot open the link you have provided.

    Please have a look at following document might helpful for you.

    https://dondeetan.com/2017/07/03/referencing-mstest-and-mstestv2-unit-testing-framework-through-namespace-aliasing/

     

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Fletch Zhou Friday, September 22, 2017 2:29 AM
    Friday, September 22, 2017 2:29 AM