Export (0) Print
Expand All

How to: Bind a Web Test to a Text File

Binding a Web test to a text file data source is similar to binding it to a database, but there are some additional steps required. Generally, the steps to bind a Web test to a text file include the following procedures:

  • Create a data source from a text file.

  • Add a text file as a data source to a Web test.

  • Bind a Web test to a text file data source.

These procedures apply to simple delimited text files, for example, comma separated value (csv) files. Delimited text files can be comma separated, or use another culture specific separator.

NoteNote

The culture specific separator can be found in the registry setting HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text\Format.

It is also possible to use more complicated text files by providing an optional schema definition file. For more information, see How to: Add a Schema Definition to a Text File Data Source.

Creating a Data Source from a Text File

To create a data source from a text file, you must set up a folder to hold your text file. The folder will act as a database, and the text file will act as a table in the database. You can have more than one text file in your database folder.

To create a data source from a text file

  1. Create a new folder, and give it a name, for example Data.

    NoteNote

    It is recommended that you create this folder on a network share. This will allow you to reuse this data in other Web tests, share this data with other testers, and use this data in a load test on a rig more easily. For more information, see About Data Binding in Web Tests.

  2. Add your text file to the directory.

Adding a Text File as a Data Source to a Web Test

Now that you have created a data source from your text file, you can add it to your Web Test.

To add a text file as a data source to a Web test

  1. Open a Web test.

  2. In the Web Test Editor, click Add Data Source.

    The Connection Properties dialog box is displayed.

  3. In the OLE DB Provider drop-down list, select Microsoft Jet 4.0 OLE DB Provider.

  4. In the Server or file name text box, type the name of the folder that contains your text file.

    Caution noteCaution

    Specify the name of the folder, not the file itself.

  5. Choose Advanced.

    The Advanced Properties dialog box is displayed.

  6. Locate the Extended Properties property, and type Text.

    NoteNote

    If your text file does not contain a header row with column names, type Text;HDR=NO; instead of Text.

  7. Click OK to close the Advanced Properties dialog box.

  8. (Optional) Click the Test Connection button to verify your connection to the file.

  9. Click OK to close the Connection Properties dialog box.

  10. The Choose Tables dialog box is displayed.

  11. In the Choose Tables dialog box, select the name of the text file that you want to use.

    NoteNote

    If you have more than one text file in the data folder, you can select all the files that you want to use. Each file is treated as a table. The period (.) in the text file name will be replaced by a number sign symbol (#), for example, TestData#txt.

  12. Click OK to close the Choose Tables dialog box.

    A Data Sources node will be added to your Web test, and the text file will appear as a table in the hierarchy.

Binding a Web Test to a Text File Data Source

Now that you have added your text file as a data source, you can bind a part of your Web test to it in the same way would to any other data source.

To bind a Web test to a text file data source

  1. Open a Web test to which you have added a text file as a data source.

  2. Find a request in the request tree that requires data, for example a request with a Form Post parameter. Select the parameter node.

  3. In the Properties window, click the drop-down arrow in the Value property and select the correct DataSource in the hierarchy. Next, choose the name of your table and the name of the field to use as the value.

  4. On the Test menu point to Edit Test Run Configurations, and then click Local Test Run.

  5. In the localtestrun.testrunconfig dialog box, select Web Test in the left pane, and then select the One run per data source row option in the right pane.

    This causes the test to run iteratively, one time for each row in the database. On each test iteration, the pointer moves to the next row in the database.

  6. Click Apply and then click Close.

  7. On the File menu click Save to save the Web test.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft