Exception handling in Web test RRS feed

  • Question

  • Hi,

    I have a series of coded web tests which I added to a web-test file to be able to run them all in sequence.
    The scenario can happen that one of the requests in one of the test cases would throw and exception.
    I want to make sure 
    1- The request which threw the exception would be marked with red-crossed icon and a comment with exception message would be displayed in the result.
    2- The rest of the web tests would run

    I added the following method to call each web test class requests but still, I can't get the crossed icon in the result.

    RunWebTestRequests(New Login(Users.CustomerPSPremiumNL))
    RunWebTestRequests(New RESTAPITest)
    RunWebTestRequests(New Logout)
    Private Sub RunWebTestRequests(webTest As ThreadedWebTest)
    		For Each r As WebTestRequest In IncludeWebTest(webTest, False)
    	Catch ex As Exception
    		Me.AddCommentToResult("Exception:   " + ex.Message)
    	End Try
    End Sub
    How can I solve this issue?

    Wednesday, October 22, 2014 10:54 AM


All replies

  • Your code fragment completely handles the exception and so it is not reported further. As well as the AddCommentToResult call you should set the Outcome property of the request.

    I have had problems with AddCommentToResult, see



    Wednesday, October 22, 2014 12:31 PM
  • Hi Adrian

    Thanks for your reply I read your post as well and it's a shame they closed the feedback request. 

    I don't like my solution because although now I can be sure that even if one or two requests fails the rest of the test cases will be executed in the intended sequence, I only get he comment in the result and as I have over a hundred test cases and the comments are not marked with distinguishable icons, it's hard to spot them fast in the report after each run. wouldn't you agree?



    Thursday, October 23, 2014 2:27 AM
  • Hi EIHam,

    If one web request fails during test run, then you will get the red crossed icon next to the web request in web test result viewer. If the web request does not fail, then you won’t get the crossed icon.

    If you only run the web test alone instead of from in a load test, you can reference Adrian’s method in this thread and write a web test plug-in to add comments for test result. As Adrian said that you should set the Outcome property of the request along with the exception information for the added comment in order to distinguish test result. The added comments won’t be marked with distinguishable icons, it is by default.

    I totally can understand your requirement. You could submit a feature request:

    The Visual Studio product team is listening to user voice there. You can send your ideas/suggestions there and people can vote.

    Thanks for your understanding.

    Best regards,

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, October 23, 2014 7:05 AM
  • Because of the problem with AddCommentToResult and because I was testing a website that had large numbers of test failures (we were unable to validate the test data in advance) I wanted a way to collect test results with data important to me. So I wrote a logging plugin, see



    Thursday, October 23, 2014 8:10 AM