Platinum Partner
java,agile,enterprise-integration,frameworks,testing,tdd

Build Tests While Building Applications

I've been doing some thinking lately about how we build and test applications. I'm no agile expert but I am impressed with the concepts of test-first and iterative development. Waterfall seems like it is designed to kill developers, testers, and projects by its nature.

I've never really understood the test-first thing in its entirety. In an SOA environment, it seems to me that test-first would put the emphasis on defining interfaces first and building tests against the interface (both good things.) The interface is just an interface. So I wonder if having some of the application logic implemented behind the interface is required to really do test-first right.

It seems to me that some sort of enhancement of agile could help here. One where I build the application and the test at the same time and iteratively.

I am trying this out using an open-source Ajax development framework (Appcelerator) and my test framework (TestMaker.) This is just a bunch of notes right now. I'm hoping to have something coded in the next 2 weeks. Here's how it would work:

Appcelerator uses non-standard tags in HTML to implement Ajax functions. For example:

<script src="javascripts/appcelerator.js"
type="text/javascript"></script>


This provides Appcelerator's function library to a page.

<input type="text" id="username" validator="required" decorator="required" fieldset="login"/>


When the page loads Appcelerator provides Ajax functions for validator, decorator, and fieldset attributes of the <input> tag.

<input type="button" value="login" activators="username,password" id="button"
on="click then r:login.request" fieldset="login"/>


The fieldset attribute is used to link <input> elements (or divs, spans) for the purpose of sending a message. The example above links the username to the submit button. When the user clicks submit the "on" attribute tells Appcelerator to click the submit button and send a login.request message to the server handling the log-in. (Appcelerator implements the server side component and the messaging for you.)

This kind of tag framework approach to application composition and development is wide spread and makes application development easier. In the above example, I didn't have to do any JavaScript work to deliver an Ajax enabled log-in page.

My thought is to extend the tags to include test definition tags. For instance:

<script src="javascripts/testmaker.js" type="text/javascript"></script>

<input type="text" id="username" validator="required" decorator="required" fieldset="login" test_input_data="dpl:mycsvfile field:username"/>

<input type="button" value="login" activators="username,password" id="button" on="click then r:login.request" fieldset="login"
test_verify="verifyTitle:Main menu"
/>



In the example above, when the page loads the testmaker.js functions respond to the test_input_data tag by reading from a comma-separated-value (csv) file using a Data Production Library (DPL.) The first row of the csv file defines field titles. TestMaker sets the username input field with the username value in the csv file.

When I want to test the page I use a test runner that loads the page and clicks the login button. The response to the login must be a page with a title of "Main menu". Otherwise, the test throws an exception and I could that as a failed functional test.

What I'm after here is a way to build the tests as we build the application.

I would love your feedback, thoughts, and ideas on this.

-Frank

From The Cohen Blog 

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}