是否应该对@Entity Pojos进行测试? [英] Should @Entity Pojos be tested?

查看:56
本文介绍了是否应该对@Entity Pojos进行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否应该测试@Entity注释的Pojos.毕竟,主要只有一些生成的getter/setter.我应该测试它们吗?

I don't know if I should test my @Entity-annotated Pojos. After all, there are mainly just generated getters/setters. Should I test them?

在测试DAO时,我正在使用所有这些实体-我猜它们已经得到了适当的测试?

When it comes to testing DAOs I'm using all those entities - so they are already propely tested, I guess?

感谢您的想法.

马特

推荐答案

您的代码可以包含任何错误吗?如果没有,那么进行测试有什么意义呢?实际上,尝试对其进行测试只会引入新的错误(因为您的测试可能是错误的).

Can your code contain any bugs? If not, what's the point in testing it? In fact, trying to test it would just introduce new bugs (because your tests could be wrong).

因此结论是:您不应在没有代码的情况下测试getter和setter(即那些仅在没有任何其他代码的情况下分配或读取字段的getter和setter).

So the conclusion is: You should not test getters and setters without code (i.e. those which just assign or read a field without any additional code).

例外是:当您手动编写这些getter/setter时,因为您可能会打错字.但是即使那样,某些代码仍将使用它们,并且应该对该代码进行测试,进而测试吸气剂/设置剂的行为是否正确.

The exception is: When you manually write those getters/setters because you could have made a typo. But even then, some code will use these and there should be a test for that code which in turn tests whether the getters/setters behave correctly.

这篇关于是否应该对@Entity Pojos进行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆