I've been using MvcRouteUnitTester (codeplex and nuget) to run automated unit tests against my routes. A taste of what it can do:
// assert incoming route
tester.WithIncomingRequest("/Foo").ShouldMatchRoute("Foo", "Index");
tester.WithIncomingRequest("/Foo/Index").ShouldMatchRoute("Foo", "Index");
// assert outgoing route
tester.WithRouteInfo("Foo", "Index").ShouldGenerateUrl("/Foo");
It works very well... when it works. It doesn't work well with MVC4 and has not been updated for a long time.
Is there a substitute tool which works with the latest MVC, and is actively supported?
There is a great new project created by Anthony Steele for testing routes in both MVC4 and ASP.NET Web API.
It was just released last week: https://github.com/AnthonySteele/MvcRouteTester
Have you checked out the forked version for MVC 4?
MVC Route/URL Generation Unit Tester
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With