Controller dependency missing on test? Try MvcContrib TestControllerBuilder
Ever faced this situation: You have nice and easy controller method, say: public ActionResult Demonstrate(string id) { this.Repository.Demonstrate(id); string url = this.Url.Action(MVC.Errors.Suck(id)); return this.Redirect(url); } Then you go and create test for it (or created the test before, whatever suits you): [TestMethod] public void Demonstrate_ValidInput_Redirects() { // Arrange var controller = new MyDemonstratingController(); // ... mock something here // Act controller.Demonstrate("kaboom"); // Assert // ... test that everything was called } …only to get NullReferenceException, since you did not set everything up that is needed by the UrlHelper class (controller’s Url property). ...