Search code examples
c#visual-studio-2017performance-testingload-testing

Adding unit tests to visual studio 2017 load test


I'm spiking on running unit tests as part of load test in visual studio 2017. I created a "Web Performance and Load Test Project" and added a simple unit test in the project.

[TestClass]
public class NotificationsTest
{
    [TestMethod]
    public void AssociateUserToDeviceTest(){
      // Unit Test Code 
    }
}

While filling details in 'load test' wizard ('projects' menu > load test), in "test mix" section when I click "add", "There are no tests available to pick" is displayed. From what I understand I should be able to find the unit tests in the project.

enter image description here

Could anyone please help me with what I'm missing and how can I added unit test load test. Thank you in advance.


Solution

  • You need to have the tests target the correct framework dll manually.

    VS Load Test will not detect unit tests in newer versions.

    Reference the following assembly instead of the MSTest.TestFramework nuget.

    Microsoft.VisualStudio.QualityTools.UnitTestFramework v10.0.0.0
    

    It should be found at

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
    

    This also limits the applicable mstest versions. But since this whole feature is being deprecated there's not much else to be said.