There’s a new preview release of SpecsFor.Mvc available on NuGet now. There are a lot of changes in this release, and there are some unavoidable, manual steps you will need to take. If no one encounters any major pain points due to this upgrade, I’ll publish the final package next week.
[more]
A Big Shout-Out
First, I want to say “THANKS!” to Antonio Bastos for his pull request. He knocked out the vast majority of the MVC 5 upgrade work, and he also did some other cleanup while he was in there.
Why the Upgrade?
So what’s the point of this upgrade? Well, the MVC team made some breaking changes with MVC 5, and they had a much bigger impact on projects like mine than they anticipated. Unlike previous upgrades, binding redirects won’t work. In order to work with an MVC 5 project, SpecsFor.Mvc had to be upgraded to reference the MVC 5 assemblies and, therefore, .NET 4.5. I was afraid this would mean SpecsFor.Mvc would be incompatible with MVC 4 (and .NET 4.0), but it appears that’s not the case. You can still test an MVC 4 application as long as your test project is targeting .NET 4.5 and references the MVC 5 packages.
That’s the main reason for this upgrade, but there’s some other goodness in here, too.
What’s Included?
First, there’s the obvious upgrade to .NET 4.5 and MVC 5.0. There are some other improvements, too, though. SpecsFor.Mvc no longer depends on MvcContrib. The one useful method from MvcContrib (the ShouldMapTo assertion) is now replicated in SpecsFor.Mvc. Breaking this dependency also allowed me to remove the dependency on Rhino Mocks.
Other NuGet packages have been updated as well. For today at least, SpecsFor.Mvc is built against the latest production versions of all its dependencies. The included Selenium Webdriver executables have also been updated.
One frequent pain point with SpecsFor.Mvc was that the test project publish step would sometimes fail if you had used the Visual Studio Publish command on the website. I’ve added a workaround for this issue, so it shouldn’t be a problem going forward.
I’ve also added an optional behavior that will clean up the published test website at the end of a test run. Just call “CleanupPublishedFiles” on the fluent API after you tell SpecsFor.Mvc to use IIS Express.
How Do I Upgrade?
Unfortunately, upgrading is a bit of a manual process. I’ve tested this procedure out on a couple of projects, and so far at least, I’ve not run into any problems. Your mileage may vary though, so please let me know of any difficulties you run in to.
- Re-target your test project to .NET 4.5 (or 4.5.1). You can do this under the test project’s Properties.
- Update to the latest pre-release build of SpecsFor.Mvc. You can do this in the NuGet Package Manager Console by running this command: “ Update-Package SpecsFor.Mvc -Pre -ProjectName [Name of your test project here]“
- Once the update has been installed by NuGet, rebuild your binding redirects by running this command in the NuGet Package Manager Console: “Add-BindingRedirect -ProjectName [Name of your test project here]”
- Replace references to MvcContrib’s ShouldMapTo assertion with the new method from SpecsFor.Mvc. It’s located in the SpecsFor.Mvc.Helpers namespace, so simply swapping out the ‘using’ statement in your affected test files should be sufficient.
Feedback
My goal for SpecsFor.Mvc has always been to provide a painless, friction-free way of creating end-to-end tests for ASP.NET MVC applications. To date, I feel like it has fallen far short of that lofty goal, and the amount of time it took me to get Antonio’s pull request integrated only made matters worse. I’ll be posting more about how I plan to avoid this problem in the future, but in the meantime, please let me know if you run into any problems with the new preview package over on Github.