问题
I have a test project in VS2010, and I need to run the unit tests from command line. On one machine the following scenario works just fine:
1) Build the tests via "MSBuild test_project.csproj"
2) Run the tests via "MSTest /testcontainer:test_project.dll"
But on the other machine the 2nd step produced a weird error message, namely: "File extension specified '.dll' is not a valid test extension"
Any idea how to tackle this?
Thanks!
回答1:
Check the registry on a PC that has Visual Studio 2010 installed: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\EnterpriseTools\QualityTools\TestTypes\.
This contains all entries in regards to allowed extensions for MSTest. It would also probably be best to search for the test type keys (e.g. {13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b}) and making sure they exist (.dll must be in the list of allowed extensions)
回答2:
If your 'other machine' is the build machine and there's no Visual Studio installed, you need to install Test Agent and Test controller (http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=1334).
Take a look at the post Running tests in mstest without installing the VS IDE (http://blogs.msdn.com/b/anutthara/archive/2009/12/16/running-tests-in-mstest-without-installing-the-vs-ide.aspx)
回答3:
If you are missing any of the following files it may cause this exception:
The files can be in the same directory or any configured directory. Configured locations can be found in MSTest.exe.config as an attribute on the probing element.
回答4:
I ran into this same problem with Visual Studio 2019, and it fact it was on a single computer. For one user account, things worked fine, but for another account, I got this error.
I realized that for the second user account, I had never launched Visual Studio.
To resolve the problem, all I had to do was to log in as that second user account and launch Visual Studio, and then MSTest worked successfully afterwards.
来源:https://stackoverflow.com/questions/4501426/mstest-file-extension-specified-dll-is-not-a-valid-test-extension