6

I'm looking for a solution to start my tests from command line.

  • I created a UnitTest Procjet in VisualStudio2017 for my .NET solution.
  • Added TestStack.White NuGet package to the project.
  • The test are running fluently when I start from the VisualStudio2017.
  • I would like to start it from Jenkins also. I think it is the easiest to do it from command line, so I add it to my pipeline configuration (Jenkinsfile)

    stage('Run UI Tests') {
        steps {
            bat('"C:\\PATH_TO_MSTEST\\mstest" /testcontainer:PATH_TO_MY_TEST_PROJECT\\bin\\Debug\\MyTests.dll')
        }
    }
    

When I try to start it from cmd like I would do with with regular Unit Tests, it is not working.
It says:

Starting execution...  
No tests to execute.

I build the project before I start 'Run UI Tests' stage.

Any ideas how to make it work? Could really find it on stackoverflow, github issues of TestStack nor other glory places on the web

Tomi
  • 3,370
  • 1
  • 16
  • 26
  • Are you trying to run these tests remotely? I know I had issues with my TFS build related to the computer not accepting UI actions while remote (solved by checking a tickbox that said "UI Tests"). – Rescis Jan 09 '18 at 03:42
  • The Jenkins runs it on an agent. I guess it is remote than. I use the Jenkins with pipeline mode, providing Jenkinsfile, telling the steps to it. – Tomi Jan 09 '18 at 16:36
  • That sounds pretty much like it should be so far as I know then. Sorry I can't be more helpful, and good luck. – Rescis Jan 10 '18 at 01:53
  • Found the solution, just about to answer it right now – Tomi Jan 10 '18 at 12:44

2 Answers2

2

Found a solution. On my local developer machine it was working, the mstest version was 14 On the build agent machine the mstest version was 15, that was not working somehow (it had nothing to do with TestStack White, simply the unit tests were not working)

What I do is, calling vstest.console.exe instead of the mstest.

C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe

So, instead of

stage('Run UI Tests') {
    steps {
        bat('"C:\\PATH_TO_MSTEST\\mstest" /testcontainer:PATH_TO_MY_TEST_PROJECT\\bin\\Debug\\MyTests.dll')
    }
}

My command in the Jenkinsfile was:

stage('Run UiTests') {
            steps {
                bat('"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\TestAgent\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe" PATH_TO_MY_TEST_PROJECT\\bin\\Debug\\MyTests.dll')
            }
        }
Tomi
  • 3,370
  • 1
  • 16
  • 26
0

nunit3-console is great alternative to MSTEST. Please refer below link.

e.g. nunit3-console \bin\Debug\Automation.dll --where "cat=Smoke-Tests"

https://github.com/nunit/docs/wiki/Console-Command-Line