Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TestStack White - Run tests from command line

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

like image 875
Tomi Avatar asked Jan 03 '18 14:01

Tomi


1 Answers

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')
            }
        }
like image 164
Tomi Avatar answered Oct 20 '22 18:10

Tomi