views:

48

answers:

4

Hi Im doing TDD for an asp.net mvc project, I need to be able to do end to end testing fie sending a request to the controller action all the way to the repository. I have tried using

http://blog.stevensanderson.com/2009/06/11/integration-testing-your-aspnet-mvc-application/ but unfortunately I cant get this to run and Im running out of time, does anyone know any other way to fake a httprequest and populate request post parameters in a test scenario my controller action is as follows [HttpPost] public ActionResult CreateUser(User user) { }

so I need to basically doa http request to populate this User object and hopefully save to a test repository. any ideas please?

Thanks

A: 

Test manually? I know this isn't what you intended, but if you don't have a lot of time, and not a lot of entry points that need to be tested, you can just as well do this the ol' way. Go to the site in your browser, post valid data to the action, and run a SELECT statement against your database to verify addition of the user and correct information. Tick the entry point off on paper, go to next.

Tomas Lycken
Hi Tomas, believe me I would if it was up to me but as I mentioned I am doing strict TDD for this project so unfortunately I need to this
Matthew
A: 

As you posted the link I'll take an extract from Steve Sanderson's blog:

Integration tests test your entire software stack working together. These tests don’t mock or fake anything (they use the real database, and real network connections) and are good at spotting if your unit-tested components aren’t working together as you expected. In general, it’s best to put most of your effort into building a solid suite of unit tests, and then adding a few integration tests for each major feature so you can detect any catastrophic incompatibilities or configuration errors before your customers do.

You shouldn't be faking HTTP requests at this stage as an integration test inherantly tests every component together.

Try some type of browser automation framework:

David Neale
A: 

If you want to do full integration testing, then test your application from user prospective. Create test cases like:

  1. Log in as admin
  2. Go to Users page
  3. Add User with name "User1"
  4. Check that user with name "User1" listed in the Users grid.

And automate such tests using Selenium or Watin. See example here

Yauheni Sivukha
A: 

Hi Guys I managed to get Steve Sanderson's Integration test framework up and running. I had to modify the source as it had issues with some of the dlls in my project naemly Nhibernate dlls and kept thowing exceptions, but its fine now and an excellent tool for integration tests

Matthew