Udostępnij za pośrednictwem


Web Test API enhancements available in VSTS 2008 SP1 (beta)

The beta for Visual Studio 2008 SP1 is now available. This article describes enhancements to the VSTS Web test API that have been added in this update. For complete details on changes and bugs fixes in this release, see Ed Glas's blog post at: https://blogs.msdn.com/edglas/archive/2008/05/27/vs-2008-sp1-beta-is-available.aspx.

 

In this update, four new methods have been added to the WebTestPlugin class (documented at https://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.testtools.webtesting.webtestplugin.aspx for VSTS 2008 RTM before these additions). These are similar to the existing PreRequest and PostRequest methods, but occur before a Web test transaction starts, after the transaction comletes, and the same for a page where a page is a Web test request defined in the Web test plus any other pages to which that page redirects and any dependent requests (such as images) that are included on the page and fetched automatically though they are not explicitly included in the Web test. Note that since these are virtual, just like the PreRequest and PostRequest methods, the WebTestPlugin author can choose to implement these or not. If not, the base class implementation is called, but it does nothing other than immediately return.

Here are the definitions of these methods:

        /// The PreTransaction callback is called just before a transaction defined

        /// in the Web test is started.

        public virtual void PreTransaction(object sender, PreTransactionEventArgs e) { }

        /// The PostTransaction callback is called just after a transaction defined

        /// in the Web test has ended.

        public virtual void PostTransaction(object sender, PostTransactionEventArgs e) { }

        /// The PrePage callback is called just before the primary request for a page is run.

        /// This allows outside code to effect the request.

        public virtual void PrePage(object sender, PrePageEventArgs e) { }

        /// The PostPage callback callback is called when the primary page and all of the

        /// dependent requests for the page have been completed received.

        public virtual void PostPage(object sender, PostPageEventArgs e) { }

There is a new EventArgs class for each of these methods, and they have these properties:

    public class PreTransactionEventArgs : EventArgs

    {

        /// Gets the WebTest containing the transaction

        /// In the case where one Web test includes one or more Web tests,

        /// this returns the child Web test that directly contains the transaction.

        public WebTest WebTest { get; }

        /// Gets the name of the transaction that is starting

        public string TransactionName { get; }

    }

    public class PostTransactionEventArgs : EventArgs

    {

        /// Gets the WebTest containing the transaction

        /// In the case where one Web test includes one or more Web tests,

        /// this returns the child Web test that directly contains the transaction.

        public WebTest WebTest { get; }

        /// Gets the name of the transaction that is starting

        public string TransactionName { get; }

        /// The during of the transaction from the time is started until completion       

  public TimeSpan Duration [ get; }

    }

    public class PrePageEventArgs: EventArgs

    {

        /// Gets the WebTest that contains the request

        public WebTest WebTest { get; }

        /// Gets the original WebTestRequest for the page (defined by the declarative or coded Web test)

        public WebTestRequest Request { get; }

    }

    public class PostPageEventArgs: EventArgs

    {

        /// Gets the WebTest that contains the page

        public WebTest WebTest { get; }

        /// Gets a WebTestPageStatistics object that contains statistics regarding the execution of the page

        public WebTestPageStatistics PageStatistics { get; }

        /// Gets the WebTestRequest that generated the response.

        public Outcome PageOutcome { get; }

    }

The WebTestPageStatistics class used above is new and has these properties:

    public class WebTestPageStatistics

    {

        /// Gets the time the page started.

        public DateTime StartTime { get; }

        /// Gets the response time for the entire page from the time the first request was issued

        /// to the time the last byte for all dependent requests was received (after following all redirects)

        /// plus any emulated network delay based on the network type in use for the Web test (or load test containing

        /// the Web test)

        public TimeSpan PageTime { get; }

        /// The total content length of all responses (including redirects and dependents)

        /// for the page

        public long TotalContentLength { get; }

    }

Comments

  • Anonymous
    June 04, 2008
    The beta for Visual Studio 2008 SP1 is now available and includes enhancements to both the Web test and
  • Anonymous
    July 27, 2008
    Visual Studio Team System for Testers Content Index for Web Tests and Load Tests Getting Started Online
  • Anonymous
    July 27, 2008
    I updated my Links to Info on Web and Load Tests post with new links. The last update was in March, so
  • Anonymous
    September 10, 2008
    This blog post will make use of the some of the new web test API's added in VS 2008 SP1. Here is a post
  • Anonymous
    September 10, 2008
    This blog will show you how to use some of the new API’s added in VS 2008 sp1 to collect additional request
  • Anonymous
    April 21, 2010
    There are some very great sources here and thank you for being so kind to post them here.