Is it important to unit test a constructor?

前端 未结 15 1640
一生所求
一生所求 2020-12-08 01:54

Ought I to unit test constructors? Say I have a constructor like this:

IMapinfoWrapper wrapper;
public SystemInfo(IMapinfoWrapper mapinfoWrapper)
{
    this.         


        
15条回答
  •  醉话见心
    2020-12-08 02:14

    Unit testing is about testing the public states, behaviors, and interactions of your objects.

    If you simply set a private field in your constructor, what is there to test?

    Don't bother unit-testing your simple accessors and mutators. That's just silly, and it doesn't help anyone.

提交回复
热议问题