MbUnit - Unit Testing on Crack
MbUnit is a "better xUnit" that's used by a myraid of folks I respect, including James Avery, Patrick Cauldwell and Phil Haack. It's under very active development, even though I'd once wondered aloud if it was "abandonware." It's decidedly not and it's just got a new facelift to prove it.
Check out James Avery's Post called "I've seen the light and it is called MbUnitr." I've asked around and everyone has nothing but nice things to say what MbUnit brings to the table. It's NOT just NUnit with some tweaks. James says it's "Unit testing on crack."
Check this out...the test will get called four times, each time with different values passed in, some intending to cause and exception and others not. Very clean and certainly nicer than making a dozen methods like "NegativeTest54".
2 [Row("James", "email@example.com")]
3 [Row("James", "", ExpectedException=typeof(InvalidUserException))]
4 [Row("", "firstname.lastname@example.org", ExpectedException = typeof(InvalidUserException))]
5 [Row("James", "mybademail.com", ExpectedException = typeof(InvalidUserException))]
6 public void AddValidUser(string name, string email)
8 User u = new User();
9 u.Name = name;
10 u.Email = email;
14 User newUser = User.Retrieve(u.ID);
15 Assert.IsNotNull(newUser, "User not found");
16 Assert.IsTrue(newUser.Name == u.Name, "Name not saved correctly");
17 Assert.IsTrue(newUser.Email == newUser.Email, "Email not saved correctly");
It's even got a feature that will rollback database changes, keeping your database fresh after each test run. Sweet. I gotta do a show on Trends in Unit Testing...