7

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?

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

4 Comments

This looks promising, but I wouldn't want to be the guinea pig. I'll look into it half a year from now. :) Until then I need something established and supported.
It worked much better with MVC4 than the other solution so I give it my vote
I'm using it and it works great for WebAPI routes and MVC4 routes. My only request would be to allow me to easily test POST MVC routes, I mean it allows me to test POST Web API routes but not POST MVC4 routes =(
This is an even better lib than MvcRouteUnitTester in the answer from Aaron Bedward, since it also tests that the controller methods are set up. With MvcRouteUnitTester you could risk having the correct route, but wrongly implemented controllers.
5

Have you checked out the forked version for MVC 4?

MVC Route/URL Generation Unit Tester

1 Comment

Yes it works. But I am interested in something new and maintained. I hope to see what others are using. If there are no suggestions, I'll accept this as the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.