简体   繁体   English

Java 模型单元测试

[英]Java Unit Test for models

Imagine an example class:想象一个示例 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?是否需要对此 class 进行单元测试?

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 eg 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.而且这种代码很容易进行单元测试,当然您也可以在集成测试期间对其进行测试——但是发现由于列名更改而导致测试失败很可能不是直截了当的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM