Is there a way to run unit tests sequentially with MSTests?

前端 未结 6 1417
走了就别回头了
走了就别回头了 2020-12-09 07:51

I am working in an application that is mostly single-thread, single user. There are a few worker threads here and there, and they are only using thread safe objects and clas

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 08:23

    I finally used the ordered test method. It works well.

    However, I had a hell of a time making it work with the NAnt build. Running only the ordered test list in the build requires using the /testmetadata and /testlist switches in the MSTest invocation block. The documentation on these is sketchy, to use a kind description. I google all over for examples of "MSTest /testmetadata /testlist" to no effect.

    The trick is simple, however, and I feel compelled to give it back to the community, in case someone else bumps into the same issue.

    1. Edit the test metadata file (with a .vsmdi extension), and add a new list to the list of tests (the first node in the tree on the left pane. Give it the name you want, for example 'SequentialTests'.
    2. If you used a /testcontainer switch for the MSTest invocation, remove it.
    3. Add a switch for MSTest -> /testmetadata:
    4. Add a switch for MSTEst /testlist:SequentialTests (or whatever name you used)

    Then MSTest runs only the tests listed in the test list you created.

    If someone has a better method, I'd like to hear about it!

提交回复
热议问题