1

I am writing an MCV3 application using Windsor as the IoC container. I am using Cassini-dev and WaitN in the Acceptance tests and have a number of basic tests which work fine.

What I normally do in my acceptance testing is fire up a new database with a unique name, populate it with some data, run the test and then through the database away.

In order to do this I need to provide my MVC3 application the new database connection string which is wired up to a configuration object passed into Windsor.

Additionally I will need to mock out a couple of components that do not exist in my testing environment and need to pass those into Windsor instead or the real objects.

If anyone has done this or something similar I would be interested to hear about your experience.

Bronumski
  • 14,009
  • 6
  • 49
  • 77

1 Answers1

0

Cassini is merely a web server and ASP.NET host, it has nothing to do with this. But you could use web.config transformations to select different configurations depending on environment. Here's an example that shows how to change connection strings.

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
  • I am using Cassini-dev which is a wrapper to cassini. It has been indicated that this is possible but not expanded on: http://cassinidev.codeplex.com/discussions/229629 – Bronumski Jun 16 '11 at 17:33
  • @Bronumski I'm aware of cassini-dev, it's still just a web server. I wouldn't use it (even if it could) to alter your application configuration. – Mauricio Scheffer Jun 16 '11 at 17:46
  • But did you see the discussion that I mentioned? It does indicate that there is something built for handling the scenario of integration tests and overriding something IoC and or web.config. – Bronumski Jun 16 '11 at 20:14
  • @Bronumski: yes I did see it, he didn't specifically say anything about solution involving solutions, and as I said, it's the wrong tool for the job anyway IMO. – Mauricio Scheffer Jun 16 '11 at 20:31
  • Wrong tool for what job? How would you suggest that a MVC3 web app be hosted in a in NUnit so that Acceptance/Integration test can be run using something like WaitN. The tests need to be run on any client machine and the CI server without having to install anything, all third party components need to be in the source controls lib folder. – Bronumski Jun 17 '11 at 08:33
  • @Bronumski: using a web server to override a component in the app's IoC configuration or overriding web.config settings is wrong IMO. – Mauricio Scheffer Jun 17 '11 at 13:22
  • But I think your missing the point this is for Integration/Acceptance testing not production. – Bronumski Jun 17 '11 at 13:48
  • @Bronumski: that's like saying that using a spoon as a screwdriver is ok because it's not at a construction site. It's still the wrong tool for the job IMO. – Mauricio Scheffer Jun 17 '11 at 13:51
  • Fair enough, your answer was what I had already done, I just wanted to make sure that I wasn't missing something. Just out of interest how would you do integration testing with an MVC app? – Bronumski Jun 17 '11 at 13:53
  • @Bronumski: personally, except for a few smoke tests, I don't do full end-to-end integration tests, they're usually too fragile to add any value. Of course this is a highly arguable topic. There are a couple of questions about integration tests in ASP.NET MVC: http://stackoverflow.com/questions/5644647/integration-testing-an-asp-net-mvc-application http://stackoverflow.com/questions/3830340/how-to-write-integration-and-system-tests-in-asp-net-mvc – Mauricio Scheffer Jun 17 '11 at 14:05
  • Edit to 4th comment: "solution involving solutions" -> "solution involving Cassini" – Mauricio Scheffer Jun 19 '11 at 19:23
  • We don't see eye to eye on acceptance and integration testing but manipulating the web config is the right answer. I didn't use transformations, xslt or xml editing but opted to use the System.Configuration library to load strongly typed configuration sections which could then be saved. – Bronumski Feb 02 '12 at 21:56
  • Oh and I didn't down vote you either, we can't have a right negative answer so I will even it out :) – Bronumski Feb 02 '12 at 21:57