views:

81

answers:

3

If you're in my position you have a big WebForms applications which have escalated to this unmaintainable thing. Things break when you add new features and you need an inexpensive maintainable way to do some kind of automated testing.

Now, from my understanding, the right thing to do would be to try building an abstraction layout of the page and user control model present in ASP.NET WebForms however, seeing as it would require a major investment in an existing application it is not an option.

I'm trying and pushing for a REST-like development as much as possible because it has some nice properties. And while doing this I've written a simple spider bot that crawls all URLs it can find and tries, simply getting them. This allowed my to quickly find bad data that was causing problems and avoid having my end-users clicking on broken things, however, this is of course not enough.

I continued work on my crawler and it's developed into a simple REST client that tries different input combination, looking for a probable bug or crash. It's more intelligent that just an exhaustive search (because it knows about the ASP.NET WebForms application layer) and my goal here is to basically explore the state of the web application, hoping to hit all the corner cases before our users.

Does anyone have any experience doing something similar?

Also, for you test gurus out there. Is this a complete waste of time, or will I be able to actually say something about the quality here? From my perspective it seems to hit a sweet spot in that it will try things a potential end user would though a browser.

As I said before, we're stuck in a bad place. And we need a simple way out of it, right now.

We've tried things like Selenium, but it mandates a lot of extra work and we change things all the time, it's just no possible to maintain multiple selenium test suits for 50 different applications.

+1  A: 

What part of your application is breaking? The UI, or the business logic?

Business logic should be completely separated from the user interface, and should be tested separately. In particular, it's much easier to use automated unit testing tools against separated business logic than it is against UI.

John Saunders
Yeah, but imagine a world we're things aren't done by the book, and haven't been done for a long time. And even if it had been, the pluming work that pushes values into the business layer could have bugs in it as well. My interface for testing is HTTP/REST that's the only abstraction layer that's dependable. This has pretty much turned into a salvage operation.
John Leidegren
+2  A: 

Of all the types of testing to implement, unit testing is both the easiest and the most likely to yield results, in terms of less bugs and more maintainable code. Get that worked out before you deal with automated integration testing

  1. Pick an IOC Container - I like Ninject for this personally
  2. Find a convenient place to inject "service" classes into your Page (the consturctor of a base Page class or override the module that loads pages, whatever works for you)
  3. Pick a unit test framework and if you don't have an automated build then set one up; include running a full suite of unit tests in that build
  4. Every time you go near a piece of logic in an aspx.cs file, see if you can't isolate it in a service and wrap unit tests around it
  5. Take a look at whether the MVP Pattern would be good for you - we found it decreased productivity as much as it increased testability (it did both a lot), but it works for some people
  6. See about slowly migrating your app over to MVC, a page at a time if necessary

And remember, you are not going to fix this problem overnight, you don't have time. Just keep improving test coverage and you'll see the benefits over time.

pdr
Thanks for your answer, have you've had any experience with MEF? Could you comment on the differences?
John Leidegren
No, sorry, I haven't. Commercially, I don't like to touch MS products [I believe it requires .NET 4?] until they're released and tested, failed fixed and tested again :)
pdr
The current MEF preview does not require .Net 4.
Darrel Miller
pdr
Both Ninject and the MVP pattern looks promising. However I'm in no place to introduce this kind of stuff at the company I'm currently working at. The typical developers lack a fundamental understanding of OOP. But I'll try and make a strong push for this in the near future.
John Leidegren
@John I had the same situation, barring one developer. I've had to push hard. Some surprised me and picked it up, others left and I'm now replacing them. It's worth the fight. Good luck
pdr
@pdr - If I ever need a new job the in the coming months, you'll have me set then, right ;)
John Leidegren
@John: If you fancy a move to London, find me :)
pdr
A: 

If i am rigth you have a large web form and want to run some standard end user tests each time you do a new release.

I can recomend the Selenium IDE adon for firefox.

it will allow you to record your user actions, e.g filling in a form, and allow you to replay those actions at any time. an easy way to run some test over a form with differnt data.

For internal code testing write some Unit tests using NUnit

TheAlbear