Search code examples
c#.netunit-testingtddbdd

Is it good practice to do unit test coverage for even plain classes


Here is an example of an class with no behaviour at all. So the question is should I be doing unit test coverage for it, as I see it as unnecessary for it does have any behaviour in it.

public class Employee
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public Address Address { get; set; }
}

My code coverage result complains that I have not done any coverage for the class


Solution

  • I never write tests for these. There's no behavior to test.

    If there were any non-trivial behavioral code whatsoever (validation code, perhaps), then I would write a test for it.