Tuesday, November 22, 2016

Jenkins - Run Visual Studio Performance and Load Tests

Introduction

Visual Studio Enterprise 2015 or Visual Studio Ultimate 2013, gives you the possibility to test the performance of your application. If you don't want to run tests in a CI you can use Jenkins.

What do you need?

1. Jenkins with MSTest Plugin installed is required. Don't forget to set the path to mstest.exe in Manage Jenking --> Global Tool Configuration:



2. Then, you have to create a new Jenkins job, set a Source Code Management (e.g. git, tfs, etc.).
Delete work-space before build starts.




3. Create batch command step that should
- restore nuget packages (if any)
- build the solution

..nuget location\nuget.exe restore "..performance project location\yourproject.sln"
..msbuild location\msbuild.exe "..performance project location\yourproject.sln " /p:Configuration=Debug

4. Create a Run unit tests with MSTest step that should contain:
- MSTest version defined in Global Tool Configuration
- performance/load tests + path
- result name to store .trx results 




5. Add a post build step of type Publish MSTest test result report like in the image below (exclude this step for a load test, included only for performance tests):




6. Finally, attach as artifacts, all .webtestResult files (for performance tests) or .trx files for load tests.





Visualize test results

For a performance test, the test results should look like this




You can notice, failure results and all .webtestResult files attached as artifacts. If you have a failed test, e.g. in this example MAINPortfolioDuplicate, just click on MAINPortfolioDuplicate.webtestResult. Open this with Visual Studio and you'll see the cause of the error.




For a load test, open .trx artifact in Visual Studio to see test results display in Test Results window.



Once you'll click on a test result, you'll see details with graphs




and errors:




Happy testing and... make it green, becomes a dream :)

No comments:

Post a Comment

Popular Posts