locked
How to filter methods inside a class test? RRS feed

  • Question

  • I have an assembly MyAssmeblyTest with many classes, Class01Test, Class02Test... and so on. I have realize that if I want to run only the test methods in one of this classes, I can use this command:

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe" -targetargs:"/testcontainer:\"M:\MyAssemblyTest.dll\" /Test:MyClass01Test"

    However, I would like to run the tests for the "create" method in Class01Test. So I tried this command:

    "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\MSTest.exe" -targetargs:"/testcontainer:\"M:\MyAssemblyTest.dll\" /Test:create"

    The problem is that it runs all the method tests in all classes which name contains "create", so that includes the methods from MyClass02Test, MyClass03Test... etc. that contains "create" string in the method name.

    But I don't know how to run only the methods that contains the string "create" in the method name only in the class MyClass01Test.

    Is it possible to do that? How I could do it?

    Thanks so much.

    Thursday, June 1, 2017 11:24 AM

Answers

  • Hi friend,

    Thanks for you post.

    I'm the only way to make it is to make sure each test method's name is unique and specify the full name in  /test: uniquename:

    reference link:

    https://msdn.microsoft.com/en-us/library/ms182489.aspx?f=255&MSPPError=-2147217396#test

    Hope it helps.

    Best regards,

    Fletch


    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, June 2, 2017 2:49 AM
    • Proposed as answer by Fletch Zhou Monday, June 5, 2017 1:28 PM
    • Marked as answer by ComptonAlvaro Monday, June 5, 2017 1:57 PM
    Friday, June 2, 2017 2:49 AM