A library for unit testing ASP MVC route tables for both Web and API Routes

Clone this repo:
  1. f85dd60 fix area things in Attribute routing by AnthonySteele · 9 years ago master
  2. cbb781b Fixed wording in default string mismatch exception by AnthonySteele · 9 years ago
  3. e301af3 Add support for specifying HTTP method in MVC fluent API by Jared Russell · 9 years ago
  4. 113b740 I have re-arranged things so that the master branch is for ASP MVC 5.1 as this is the latest version by AnthonySteele · 9 years ago
  5. 06a7044 update buildpackage script by AnthonySteele · 9 years ago



MvcRouteTester is a .Net library to help unit testing ASP MVC route tables. It contains asserts for for both regular controllers and the Api controllers that are new in MVC 4.0. It is built in .Net 4.0 and ASP MVC 4.0 or ASP MVC 5.0.

It can be used with a simple or a fluent syntax, e.g either RouteAssert.HasRoute(routes, "/home/index"); or routes.ShouldMap("/home/index").To<HomeController>(x => x.Index());


To aid automated testing by allowing unit tests on routes. Without such a library, the only way to automate a test that your ASP MVC application responds to a certain route is to make an integration test which fires up the whole MVC application in a web server and issues a Http request to that URL. Integration tests are good too, but unit tests run faster, easier to configure, are less fragile and generally come earlier in the coding life-cycle, so there are good reasons to use unit tests as a first line of defence against route configuration errors.


MvcRouteTester throws an exception in order to fail a test on a route. This should work in any unit testing framework. However, if you want to integrate closer with NUnit or another unit testing framework, you can do this.


Copyright 2013 Anthony Steele. This library is Open Source and you are welcome to use it as you see fit. Now the official wording:

It is licensed under the Apache License, Version 2.0 (the "License"); you may not use library file except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Where can I get it?

You can get the binaries for ASP MVC 5.1 or for ASP MVC 5.0 or for ASP MVC 4.0 from NuGet.org.

You can get or fork the source here on GitHub. The master branch is used for ASP MVC 5.1 as this is the latest version, and there are branches for MVC 5.0 and for MVC 4.

Other pages