JUnit tests for POJOs

后端 未结 17 1668
Happy的楠姐
Happy的楠姐 2021-02-02 07:56

I work on a project where we have to create unit tests for all of our simple beans (POJOs). Is there any point to creating a unit test for POJOs if all they consist of is gette

17条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 08:06

    I don't think there's a point to testing simple property getters and setters. The point of unit-testing is not to verify that your compiler works.

    However, as soon as you add a conditional, null-check or other non-trivial behavior to your getters and setters (or other methods) I think it's appropriate to add unit tests.

提交回复
热议问题