I've seen this question come up several times recently, so I'm going to try to provide the full answer here. Let me start by saying that we have some significant changes in the pipeline that will make calling a web test from another web test a fully supported feature in a future release. Until then, I do not recommend it due to the gotchas listed below.
That's quite a list of gotchas, but calling a web test from another web test can still be done if you're not depending on databinding, transactions, the context, or plugins.
If you still want to call a web test from a web test, the code should look like this:
public override IEnumerator<WebTestRequest> GetRequestEnumerator(){ WebTestRequest request1 = new WebTestRequest("http://localhost/"); yield return request1;
WebTest2Coded webTest2Coded = new WebTest2Coded(); IEnumerator<WebTestRequest> webTest2Enumerator = webTest2Coded.GetRequestEnumerator(); while (webTest2Enumerator.MoveNext()) { yield return webTest2Enumerator.Current; }
WebTestRequest request2 = new WebTestRequest("http://localhost/"); yield return request2;}
Again, I do not recommend calling web tests from other web tests in VS 2005. It would be best to wait for the next release when it will be a fully supported feature.