So standard Agile philosophy would recommend making your domain classes simple POCOs which are Persisted using a separate proxy layer via data access objects (like NHibernate does it). It also recommends getting as high unit test coverage as possible.
Does it make any sense to write tests for these simple POCO objects? Say I have a class which looks like this:
public class Container {
public int ContainerId { get; set;}
public string Name { get; set;}
public IList<Item> Contents { get; set;}
}
What useful unit tests can I write for this?
A typical unit test contains 3 phases: First, it initializes a small piece of an application it wants to test (also known as the system under test, or SUT), then it applies some stimulus to the system under test (usually by calling a method on it), and finally, it observes the resulting behavior.
To diagnose DDD, you may need to have some imaging tests. You may have an x-ray, which can help your surgeon "see" the bones in your spine. X-rays are effective at showing narrowed spinal channels (spinal stenosis), fractures, bone spurs (osteophytes), or osteoarthritis.
No. Such test provide little to no value as you will be creating model instances in other tests, for components that work with/use said models. As such, you don't need dedicated model tests because they will be tested indirectly many, many times.
Typically a value object like that doesn't need to have its own tests. You'll get coverage from the classes that use it to actually do something.
The unit tests are designed to test behavior. No behavior? No need for a test.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With