I am of the Idea that a test should only have one assert.However at times is difficult to decide if i need to be strict about it or depends.
Lets take an example I have a customer with address.
The Address Class has City-Street-PostCode-Country etc… properties
I would like to test if when Creating a customer the address gets populated.
Shall I create one test per property or many asserts
Assert.That(customer.Address.City,Is.EqualTo("London"));
Assert.That(customer.Address.Street, Is.EqualTo("StreetOne"));
Assert.That(customer.Address.Postcode, Is.EqualTo("MyPostCode"));
What do you normally do when testing a method and is important that you know that properties have been filled as they are going to a third party ?
thanks for any suggestions
I would say, it depends. In your case I don’t really see a problem with it as your are basically testing a single piece of functionality (creating a customer). Even NUnit has a shortcut for this type of thing via the TestCase attribute.