0

What Im trying to achieve is to write UI tests for my MVC4 web application using Watin. Now I create a Browser object and open on URL localhost:xxxxx.

Problem is that the code running on localhost:xxxx using IIS Express is using production code which I dont want to be doing during test. In test I want for instance my IAuth and IDataProvider implementations to behave differently.

How do you UI test on a mocked instance of your application?

Ideas? :)

AndersLindas
  • 137
  • 1
  • 9
  • Deploy with a different Dependency Injection container configuration? – jessehouwing Dec 20 '13 at 12:36
  • But then I'd ned to remember to deploy with this configuration each time I want to run test. I was hoping to avoid this. But I guess, if there is no other way I have to do it like that :) – AndersLindas Dec 20 '13 at 14:11
  • You could use WebDeploy with a specific Publish Profile, that would make it easy to deploy the correct code. – jessehouwing Dec 20 '13 at 18:01
  • My final solution was to create a bat file that I run 1 time before my UI tests which reset database to a given state and run msbuild command with DeployOnBuild. Works like a charm :) Thanks for your input guys – AndersLindas Jan 20 '14 at 09:32

1 Answers1

0

Solution was to make a bat file which runs a msbuild command which deploy to my local IIS. This works like a charm.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\Source\...\ProjectName.csproj       /p:DeployOnBuild=true /p:PublishProfile="UnitTest" /p:Platform="Any CPU" /p:OutputPath="C:\inetpub\web" /p:VisualStudioVersion=11.0
AndersLindas
  • 137
  • 1
  • 9