tags:

views:

158

answers:

4

I am writing a web application that is very complex in terms of UI and relies heavily on AJAX, DOM and image manipulations.

Is there any standard practice (I don't want tools) which can be followed to reduce the bugs?

+8  A: 

A very simple technique is the smoke test, where you automate a click-through of all of your application. If the script runs and there are no errors anywhere in the logs, you have at least one defined level of quality.

This technique actually catches a fair amount of regression breaks and is much more effective than it sounds like. We use selenium for this.

krosenvold
Do you mean a functional testing with specific test scenarios or it's just - click every possible target?
The simplest version we do is to click through the use cases that are our main deliverables. At minimum we also include main alternate/error flows. This does not necessarily mean we'll click every button/item there is.
krosenvold
+2  A: 

Watin is a great tool for this.

Chris Ballance
+1  A: 

A simple checklist (even on a piece of paper!) is the best way to make sure you never skip the important things. It's a good "smoke test" that nothing "standard" has been broken.

Jason Cohen
+5  A: 

Separate the logic and the UI portions - do not have all your business logic and complex code in the code behind page. Instead build them off the standard tier structure (data layer, business rules / logic layer, UI layer). This will ensure that your logic code you want to test does not reference the form, but instead uses classes that are easily unit tested.

For a very basic example, don't have code that does this:

string str = TextBox1.Text.ToString();
//do whatever your code does
TextBox2.Text = str;

Instead extract the logic into a separate class with a method:

TextBox2.Text = DoWork(TextBox1.Text.ToString());

public class Work
{
    public string DoWork(string str)
    {
      //do work
      return str2;
    }
}

This way you can write unit tests to verify that DoWork is returning the correct values:

string return = DoWork("TestThisString");

Now all of your logic is unit testable, with only code that HAS to reference the page directly still in your UI layer.

Carlton Jenke