Java模型的单元测试

huangapple go评论84阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年4月7日 02:18:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/61066330.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定