3

This is the command I use to run all NUnit tests from specified library

vstest.console.exe "PATH_TO_REPOSITORY\Tests\terminalBaseTests\bin\debug\terminalBaseTests.dll" /logger:trx /TestAdapterPath:"PATH_TO_REPOSITORY"

This dll contains 27 tests but I see that they launched for some reason 3 times and the resulting message says that 81 tests were passed

Demarsch
  • 1,419
  • 19
  • 39
  • Did you ever resolve this problem? I am having the same issue with xUnit in TFS 2015's new build system – PascalK Jul 12 '16 at 16:17
  • 2
    Yes. In my case it was caused by the fact that path to test adapter was not specified thus VS tried to scan all dlls that were produced during the build and one dll that contained test adapter was discovered more than once. A fix was to set path to test adapter to one particular dll location – Demarsch Jul 12 '16 at 21:47

1 Answers1

3

Demarch provided the correct answer in the comments, for visibility and whenever other people are stumbling upon this issue I will state it here (it took me way too long to figure this out):

Symptom:
VSTest.Console.exe is running tests twice or even multiple times when NUnit, Xunit or another testrunner is used than the native one.

Cause:
The path to the TestAdapter is not correctly (to $(Build.SourcesDirectory) for example) set or not present. This is letting the runner scan all folders for test adapters. When there are multiple present, all testadapters will start a testrun causing all tests run multiple times.

Solution: Redirect the path to the testadapter to the folder your packages are in.

  • If you run from the commandline set the following parameter for VSTest.Console.exe to something like this: /TestAdapterPath:"{solutionfolder}\packages"
  • If you run it in TFS, open the "Advanced Executions Options" section of the Visual Studio Test build step and set the following parameter to something like this: $(Build.SourcesDirectory)\packages
AutomatedChaos
  • 7,267
  • 2
  • 27
  • 47