views:

133

answers:

1

I need to stop a web test from running if an extraction rule fails.

The Extract method of the extraction rule class looks like this:

public override void Extract(object sender, ExtractionEventArgs e)
{
    try
    {
        // fancy logic going on here
    }
    catch (ExtractionException ex)
    {
        e.Message = ex.Message;
        e.Success = false;
    }
}

The solution I was thinking about is to define a StopTestRequestPlugin class derived from WebTestRequestPlugin and in the body of the PostRequest method to check if any of the extraction rules failed and stop the test. This way, I can assign this class to any test, without changing the code for the test or for the extraction rules involved.

Is there a way to access the ExtractionRule objects which had the Extract methods set as event handlers for the request?

I'm using Visual Studio 2005 and .NET 2.0.

Thanks.

A: 

Can you not check the eventargs.Success property from inside the webtest? A simple if statement should suffice to prevent the successive requests in the webtest from executing.

Nat
Thanks for the answer, Nat. Something like that probably, but I want to iterate through all the ExtractionRules assigned to a request, and this is what I don't know how to do. Moreover, I want the solution to be as flexible as possible, to be able to use it with any test, without modifying the webtest or extraction rules code, therefore I thought maybe a WebTestRequestPlugin would be suited.
Paul