I am testing the UI of my ASP.Net Web Forms app using NUnit/Watin. I understand the high level concepts around TDD, Unit Testing, integration testing etc, but have not had much of a chance to put them to use until now.
So, when I am testing the validation logic on a data entry form, should I be writing one test that triggers each of my validation errors (i.e. Field x is required), or a separate test for each of the validation errors that should be thrown by the form. Is this simply a style issue, or are there valid reasons for writing several tests instead of one that hits on all possible combos of my validation logic?
Psuedo code:
[Test]
public void Validation()
{
//Do some stuff to test that username is required.
Assert.AreEqual(true, ie.ContainsText("Username is required.");
//Do some stuff to test that passwword is required.
Assert.AreEqual(true, ie.ContainsText("Password is required.");
}
vs.
[Test]
public void ValidateUserName()
{
//Do some stuff to test that username is required.
Assert.AreEqual(true, ie.ContainsText("Username is required.");
}
[Test]
public void ValidatePassword()
{
//Do some stuff to test that passwword is required.
Assert.AreEqual(true, ie.ContainsText("Password is required.");
}