Test Review #2 – ASP.NET MVC Unit Tests

By Roy Osherove In .NET, .Net 2.0, .Net Original, Agile, Art Of Unit Testing, TestReview, Testing Guidelines, Unit Testing

Markdown version

Historical article · Originally published March 21, 2009; technical details may be outdated.

See other reviews:

Here’s the second video review of Unit Tests. This is another one written by Microsoft – ASP.NET MVC (source).

First, it’s important to state how surprised I was by the high quality of the tests in MVC. The tests are readable, maintainable and trustworthy, with very little issues that I could find. whatever Issues I found are rather easy to fix. In any case, if one is looking for examples of systems written in what seems almost entirely in TDD, or at the minimum with very good testing guidance, ASP.NET MVC should be a good stop to look at.

see the video here

Issues discussed in this video:

  • Implementing RowTest with MSTest, and the importance of naming (14:00)
  • Verify() that is splitted from the mock expectations (17:00)
  • some naming conventions
  • Over-specification in tests (mainly more than one mock object per test)
  • verifying mocks when it’s not required
  • logic inside tests (concatenation)
  • test factory methods with too much logic
  • a very good example of when multiple asserts is really bad (11:50)

Again – I’m very pleased with the test quality. Now is the time to make sure the things above are fixed. they are still important!

Lessons on this topic

More in .NET

All posts in .NET