spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / web / articles / htmlform / testing

A Note on Testing

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

Programming with HTML Forms

In the early stages of form design, it is useful to test the form without having to write the accompanying application. For instance, early form testing involves checking what default values are posted if the user immediately presses the submit button.

One possibility is to set the FORM ACTION to point to qgp (or a program like it), which echoes name=value pairs. An alternative is to set ACTION to:

This program does much the same thing as qgp. The drawbacks are longer network access time, and the inability to modify the application to test specific form features.

Testing is also a problem with form applications, since it is not possible to run their user interface (i.e. the input document running in a browser) inside a source-level debugger. In normal circumstances, if the application fails, the browser returns a cryptic message.

The easiest way to avoid this problem is to test a modified version of the application which reads name and value pairs from the keyboard. A fragment of code which illustrates this idea for qdir.c is shown below. It reads strings straight into the val fields of the entries array. Since the name fields are not used in this application, they are not assigned values.

    char line[MAXLEN]; etnum = 0; printf("Enter string 1:"); while ((etnum < PATNO) && (gets(line) != NULL)) { entries[etnum].val = (char *) malloc(sizeof(char)*(strlen(line)+1)); strcpy(entries[etnum].val, line); etnum++; if (etnum < PATNO) printf("Enter string %d:", etnum+1); }

Output will be sent to the screen, but is usually quite readable if the printf()'s include some newlines along with the required HTML formatting instructions.

Comments are welcome

Copyright 1996 Andrew Davison and


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger

Created: Apr. 26, 1996
Revised: May 7, 1996

URL: http://webreference.com/htmlform/testing.html