Choosing the Right Command Line Tool for Running Tests in Visual Studio

Choosing the Right Command Line Tool for Running Tests in Visual Studio

16 July 2024 Stephan Petzl Leave a comment QA

When working with Visual Studio 2013, TFS, and MTM, developers often need to run tests from the command line. Among the available tools—tcm.exe, mstest.exe, and vstest.console.exe—selecting the right one can be challenging. This guide will help you understand the differences between these tools and choose the one best suited to your needs.

Overview of Command Line Tools

Each tool is optimized for specific types of test automation. Here’s a breakdown of their primary use cases:

  • tcm.exe: Used for running Team Foundation Server (TFS) or MTM test cases associated with automation. It runs the test cases rather than directly executing the tests and automatically updates the test case status. Essentially, it acts as a command line wrapper around MTM’s automation capabilities.
  • vstest.console.exe: Designed for running Microsoft unit tests and Microsoft CodedUI tests. This is the tool to use if you are working with modern test frameworks and need support for recent features, including Fakes.
  • mstest.exe: The legacy tool that runs anything Visual Studio recognizes as a test. Essential for load and performance tests created in Visual Studio and can send test results to TFS.

Detailed Comparison

To make an informed decision, consider the following aspects:

  • Test Type: Identify the type of tests you need to run. For instance, if you are working with unit tests or CodedUI tests, vstest.console.exe is your best bet. For load and performance tests, mstest.exe is more suitable.
  • Feature Support: Newer features, such as Fakes, are supported by vstest.console.exe. However, some older features, like database unit tests, load tests, and web tests, are only supported by mstest.exe.
  • Integration with TFS/MTM: If your workflow involves TFS or MTM test cases, tcm.exe should be your tool of choice as it integrates seamlessly with these platforms.

Practical Examples

Let’s consider a few scenarios to illustrate the use of these tools:

  • Scenario 1: You need to run unit tests and leverage the latest features like Fakes. In this case, use vstest.console.exe.
  • Scenario 2: Your project includes load and performance tests created in Visual Studio. Here, mstest.exe is the appropriate choice.
  • Scenario 3: Your tests are associated with TFS/MTM and you want to update the test case status automatically. Opt for tcm.exe.

Conclusion

Choosing the right command line tool depends on the specific requirements of your testing scenario. By understanding the strengths and limitations of tcm.exe, mstest.exe, and vstest.console.exe, you can select the most appropriate tool for your needs.

For more detailed guidance on running tests and managing test cases, you can explore our documentation on running test batches and test exception handling.

Enhance Your Testing with Repeato

If you’re looking for a no-code solution to simplify and accelerate your test automation, consider using Repeato. Repeato is a powerful tool that allows you to create, run, and maintain automated tests for iOS and Android apps using computer vision and AI. It’s particularly fast to edit and run tests, making it an excellent choice for quality assurance teams looking to enhance their testing efficiency without diving into complex coding tasks.

Like this article? there’s more where that came from!