英文:
Java Unit Test for models
问题
想象一个示例类:
public class Debit extends AbstractDebit {
@Column(name = "ID_PESSOAS", updatable = false, insertable = false)
private Long idContribuinte;
...更多字段在这里
这个类需要进行单元测试吗?
英文:
Imagine an example class:
public class Debit extends AbstractDebit {
@Column(name = "ID_PESSOAS", updatable = false, insertable = false)
private Long idContribuinte;
...more fields here
Is necessary a unit test of this class?
答案1
得分: 0
我认为这是一个适合单元测试的有效案例;我理解对于您的应用程序,名称和其他属性对于其正常工作至关重要,而且当您希望发现破坏性更改时(例如,如果开发人员更改了该名称),我认为越早发现越好。当然,在集成测试期间也可以测试这种类型的代码,但是发现测试失败是由于列名更改很可能不是一件直接的事情。
英文:
I think it is a valid case for unit tests; I take it that the name and the other properties is important for your application to work as expected, and when do you want to spot a breaking change (for e.g. if a developer changes that name)? I say as early as possible. And this kind of code is easy to unit test, of course you can test this during integration testing as well - but finding out that a test fails due to a column name change will most likely not be straight forward.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论