07.11.2014 Views

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Test</strong>ing for Performance and Scalability 177<br />

After you create the test, you can convert the recorded Web test to a coded Web test.<br />

<br />

To convert a recorded Web test<br />

1. Open a solution that contains a recorded Web test.<br />

2. Open the Web test file.<br />

3. In the Web <strong>Test</strong> Editor, click the Generate Code button. You are prompted for a<br />

name for the coded Web test.<br />

4. Type a name, and then click OK.<br />

5. Click Build, and then click Build Solution. Your code compiles. The compiled<br />

code is a test script.<br />

When you build your test harnesses, remember two points:<br />

●<br />

●<br />

Do not cache an application block's internal domain objects over iterations of the<br />

tests to avoid the costs of creating them. Performance tests should assume the<br />

worst case scenario, which is the most expensive code path. For example, the<br />

Caching Application Block's most expensive code path is when the application<br />

block creates a CacheManager object. The most expensive path for the Logging<br />

Application Block is when the application block creates a LogEntry object. For an<br />

example of how to create a CacheManager object, see Using the <strong>Test</strong> Script.<br />

Do not distort the TPS measurements made with the performance monitor (ASP.<br />

NET: Requests/sec) and the Visual Studio 2005 Team Edition for Software <strong>Test</strong>ers<br />

load test tool by reloading the Web page after the first request. Instead, read the<br />

ViewState and EventValidation variables (and any other static variables that the<br />

Web server returns).<br />

There are two ways to implement these suggestions. You can either edit the test script<br />

or you can use data binding. For information about editing the test script, see Using<br />

the <strong>Test</strong> Script. For information about using data binding, see Using Data Binding.<br />

Using the <strong>Test</strong> Script<br />

You can add code to the test script to maintain the state of the Web page. This means<br />

that the entire page is loaded only once, when the first user accesses it. The values<br />

from the page and all of the controls are collected and formatted into a single encoded<br />

string and then saved in the _VIEWSTATE hidden field. In the example given<br />

here, the test script stores this string in the ViewState variable. The test script tests<br />

the ViewState variable to see if it is null. This is the equivalent of seeing if this is the<br />

first time the page has been loaded. If the value is not null, the test script reloads the<br />

page but executes only the POST request path, along with the required test actions.<br />

The test script also uses the __EVENTVALIDATION hidden field. This field acts as<br />

security against fraudulent postbacks. It validates any events (such as clicking a button)<br />

that occur. The EventValidation variable stores the value of the field.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!