It’s a fact that coded web test methods give more flexibility to the developer, i.e. common code reuse. So let’s create a coded web test in whose GetRequestEnumerator() method you want to call a common method which tests some other requests. Let’s make it look as GetCommonRequests() in the example below:
public class AWebTest : WebTest
{
private IEnumerator<WebTestRequest> GetCommonRequests()
{
WebTestRequest req1 = new WebTestRequest("http://google.com");
yield return req1;
WebTestRequest req2 = new WebTestRequest("http://google.com");
yield return req2;
}
public override IEnumerator<WebTestRequest> GetRequestEnumerator()
{
WebTestRequest req = new WebTestRequest("http://google.com");
yield return req;
GetCommonRequests();
}
}
You would expect to see three requests in the test result. You will see only one though…
Continue reading ‘How to invoke a common coded web test method from GetRequestEnumerator()?’

![C# 3.0 Pocket Reference: Instant Help for C# 3.0 Programmers Photo Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=77cd8280-a5ff-4ddd-a644-0a6accf2f070)

