Monday, July 12, 2004

NUnitAsp First Impressions: I Like It

I've been playing around with NUnitAsp for about 15 minutes now, and I already like it a lot. It gives the ability to make requests to an ASP.NET web page, and then easily verify that the contents of various server controls have rendered correctly. And it plugs into NUnit, so you get that same red/yellow/green display. I even managed to make it populate a login form with my credentials, click the submit button, and verify that it redirected me to the right page. Took about three minutes to write.


In addition to being useful for doing TDD of web apps, this is definitely something that should make writing build verification tests easier. Build verification tests (BVTs) are distinctly different from unit tests, in that they are intended to work against the system as a whole, rather than against a small piece of code. So as one of its last steps, the build script can copy the newly compiled web content to the file system, create a virtual directory, then use nunit-console to run tests that hit various pages, making sure everything works okay as deployed.

8 comments:

  1. Have you created a test using roles from your user object?

    ReplyDelete
  2. I was having difficulty setting up test users and submitting their credentials. The error I was making was I used something other than Basic authentication. Once you use Basic authentication, my problem was solved.

    ReplyDelete
  3. Huh. He seems to say, "Unit tests don't test all these other aspects of code", but in about 1000 words. Well, I agree: they don't test a lot of things. So what? They're still super, super useful. I've caught literally dozens of errors - both straight implementation errors and regression problems - using TDD. So people can call it "hype" if they want to, but the simple fact is that *I* find it enormously useful...as much so as a debugger, another tool some people point and say, "If you use this, it's because your code sucks."



    Point is, unit testing is just another tool in the arsenal. Like a debugger, it doesn't eliminate the need for other types of testing and validation.

    ReplyDelete
  4. I noticed that you create an IIS virtual directory as part of your Build Verification Test scripts. How do you script this? And for the bonus round, how do you edit where a virtual directory points -- programmatically? Automation is key.



    Thanks,

    Eli

    ReplyDelete
  5. There are about 1000 ways to create a virtual directory. I've done everything from writing custom JScript to using the NAnt mkiisdir task to running the iisvdir command.



    Editing where a vdir points is pretty trivial if you just delete and recreate the vdir as part of the build. Otherwise you can always write some script to just edit the Path property in the Metabase.

    ReplyDelete
  6. hi

    i am using nunitasp for requesting for webserver and getting reaponse from that. for this i have set the headers for that server. i didn't find httpresponse and httprequest as i have taken class library for testing purposes.

    if u have any idea regarding this please help me out.

    regards

    request.

    ReplyDelete
  7. Sorry - since posting this, I've barely used NUnitAsp at all, so I don't know how to help you.

    ReplyDelete