What command line arguments does Visual Studio use for running MsTest? - visual-studio-2010

I'm trying to figure out which is the command line arguments used by Visual Studio when you run the MsTest tests, I guess it starts with:
MSTest.exe /testmetadata:%SolutionName%.vsmdi /testlist:
But I couldn't figure out how to fill the testlist parameter, because both the test list name and id get the following error:
The test list path 8c43105b-9dc1-4917-a39f-aa66a61bf5b6 cannot be found.
An error occurred while executing the /testlist switch.

I'm trying to figure out which is the command line arguments used by
Visual Studio when you run the MsTest tests
It depends on how do you run your tests from Visual Studio. See the following examples:
You are selecting some tests from the Test View window and run them
MSTest.exe /testcontainer:TestProject.dll /test:TestMethod1 /test:TestMethod2 ...
Your are running all the tests from the Test View window
MSTest.exe /testcontainer:TestProject.dll
You have filtered your tests by a category through Test View window and run this category
MSTest.exe /testcontainer:TestProject.dll /category:CategoryName
You have opened the *.vsmdi file and selected some TestLists to run
MSTest.exe /testmetadata:*.vsmdi /testlist:TestList1 /testlist:TestList2 ...
You are running Load or Ordered tests
MSTest.exe /testcontainer:LoadTest1.loadtest /testcontainer:OrderedTest1.orderedtest
You can combine the above examples (arguments) to create the MSTest command that suits on your case. The only restriction you have is that you cannot use the /testmetada and /testcontainer arguments together.
As for the TestList argument you just need to give as parameter the name of the list. If it is not found then your test list does not exist or it does not belong to the *.vsmdi you have defined on the /testmetadata argument.
I am sure that you have already done it, but you can check the following link:
MSTest.exe Command-Line Options

See following link. Even though this post is about msbuild. It uses exec task for calling mstest.
If you use /testlist you need to give metadata file.
You can use /testcontainer and give dll for your test project. It will run all of your tests.
/testcontainer:[file name] Load a file that contains tests. You can
Specify this option more than once to
load multiple test files.
Examples:
/testcontainer:mytestproject.dll
/testcontainer:loadtest1.loadtest

Related

How to generate .trx result file after TFS build instead of code coverage?

I recently added xxx.runsettings file to my solution to pass parameters from TFS variables to my solution(url). Now I'm not able to generate .trx result file after running TFS build in Test summary/results page, only code coverage is generated.
[.runsettings code taken from here-https://msdn.microsoft.com/en-us/library/jj635153.aspx
Can anyone here tell me how to edit the runsettings file in order to show .trx result file in my test summary instead of code coverage?
TFS 2015 Update 3,TFS ms build
Can see this window once build is completed.
Run functional test Logs
Publish results log -
Logs
2017-06-21T17:20:49.9138829Z Executing the powershell script: C:\agent\tasks\PublishTestResults\1.0.22\PublishTestResults.ps1
2017-06-21T17:20:50.0628925Z ##[warning]No test result files were found using search pattern 'C:\agent_work\2\s**\TestResults\xyz*.trx'.
Just remove <ResultsDirectory>.\TestResults</ResultsDirectory> section from the runsettings file should fix your issue.
By the way, Publish Test Result task does not work in your scenario since it can only publish the test result files on the build agent while the trx file is usually generated on the test agent with Run Functional Test task.
Since you are running the VStest. Which will not generate the .trx result file.
VStest step is actually using VSTest.Console.exe command, it will use the /logger:TfsPublisher which not generate the .trx file. So if you use the built-in tasks such as Visual Studio Test or Run Functional Tests to run tests, results are automatically published and you do not need a separate publish test results task.
To log results into a Visual Studio Test Results File (TRX) use /Logger:trx. More details please refer this command. To generate a .trx file is not related to runsettings file.
For TFS , the test result is automatically published, you could click test run for more details.

BDD Tests are not recognized in command level

I am trying to run Specflow BDD tets in command line and looks like it doesn't recognized those tests. But I am able to run them in VS IDE
Not sure whether there is a path issue.
I tried other options as in the below link as well. No luck though
How do you run SpecFlow scenarios from the command line using MSTest
The Problem was, that the code-behind files of the feature files were not generated properly, because the configuration of the unitTestProvider was missing.
See the documentation for that here: http://www.specflow.org/documentation/Configuration/

TeamCity and CTest test results

I have a number of unit tests written for my project, executed with CTest. I would like to integrate the results into my TeamCity build. I've downloaded and set up the plugin for my testing framework (Boost Test).
The problem that I have run into is that the tests run with CTest output to Testing/Temporary/LastTest.log, whereas TeamCity is trying to read the results from standard out. To get around this, my testing step is.
make test
cat Testing/Temporary/LastTest.log
which works, but feels like a hack.
Is there any way to get TeamCity to read from this file in addition to standard out? Alternatively, is there any way to tell ctest to output to standard out in addition to this LastTest.log file?
This question is similar, but I would like it to work for all output rather than just on failure: CMake: setting an environmental variable for ctest (or otherwise getting failed test output from ctest/make test automatically)
Teamcity has additional build features which allow to process CTest reports. I am not sure if it'll work or not but you could try adding an additional build feature in your build step to read CTest report.

Running Mstest.exe without team foundation server.

I want to run tests in comman line using mstest.exe. Here is the command which I am trying to execute
MSTest.exe /platform:[x64] "/testcontainer:D:\Dev\tas\Tests.dll" /resultsfile:"D:\Dev\TestResults.xml"
But everytime I am getting error.
No Build Uri specified for publish operation.
For switch syntax, type "MSTest /help"
I am not using any teamFoundation server. How do I run this?
The /platform command line option is actually related to the publishing, not test execution (as described at http://msdn.microsoft.com/en-us/library/ms182489(v=vs.100).aspx). When you specify at least one publishing option, MSTest validates that the minimum required set of publishing options have been supplied.
Since you don't really want to publish, simply getting rid of the /platform option should fix the problem.

Which MSBuild tasks initiate a call to SGen?

I have inherited a complex MSBuild script which builds & deploys multiple solutions. When I run the script I see the following error in log:
SGEN: Cannot generate serialization assembly
C:\B\268\Agents\Agents.XmlSerializers.dll
because it already exists. Use /force to force an overwrite of the
existing assembly.
I agree that Agents.XmlSerializers.dll exists. What I can't determine is which task caused it to be created and which one initiated the attempt to re-create it.
I have searched through the files in the build hierarchy for 'SGen' and found nothing. So I presume that SGen is called implicitly by two (or more) of the tasks in the build.
Can anyone point out what might call SGen?
Thanks.
In the Build Output window, look for...
Task "SGen"
Right above that is the actual "sgen.exe" command.
And as Pawell said, you need full details in your build output. Inside of Studio, it's Tools - Options... - Projects and Solutions - Build and Run - MSBuild project build output verbosity: Diagnostic.

Resources