Ville Salonen
Ville Salonen

Reputation: 2654

Fail load test when individual test cases fail

I've implemented load test suite using MSTest test cases with Visual Studio 2015. I can execute the load test fine but I'd like to fail the load test run if there are any test failures. Now I get a green success symbol with text "Test run completed Results 1/1 passed" and I have to dig deeper into load test report to notice that actually some or even all test cases failed.

Is this possible?

UPDATE:

I was too vague in describing my setup. To clarify there are:

I understand that typically load tests use Web Performance Tests (.webtest) which can be recorded using a browser. I opted to use MSTest tests instead because the system under test is a WCF service and not a web page so tests would be hard to create as I couldn't use browser recording.

I have this setup up and running and I can see how my system under test performs. Only problem is that if some these MSTest executions fail (e.g. Assert.AreEqual fails), I can see the errors when I read detailed test report but if one just quickly glances at the report and sees "Test run completed Results 1/1 passed", they might think that performance test was a success even though at least some or even all MSTest executions failed.

Upvotes: 1

Views: 648

Answers (1)

AdrianHHH
AdrianHHH

Reputation: 14038

The result of a web test can be set to pass or fail in code, eg

public class xxx : WebTestPlugin // also based on WebTestRequestPlugin

{
    public override void PostRequest(object sender, PostRequestEventArgs e)
    {
        e.WebTest.AddCommentToResult("Outcome was " + e.WebTest.Outcome.ToString());
        e.WebTest.Outcome = Outcome.Fail; // to force a failure
    }
}

I have not found a way of setting the outcome for an entire load test. The outcome for the individual tests is accumulated.

Upvotes: 1

Related Questions