I don't see what a database has to do with unit testing. If you are talking about integration testing that's whole other story but a unit test should never hit a database, so to answer your question: no, database default values do not break the spirit of unit testing.
I put default values in the database if it's going to be an integration point between applications. Whenever I do use a default value, I always set that property in the constructor of my entity to the same value. So in this sense, I don't see why it would invalidate unit testing.
发布评论
评论(2)
我不明白数据库与单元测试有什么关系。如果您谈论的是集成测试,那就完全是另一回事了,但是单元测试永远不应该访问数据库,所以回答您的问题:不,数据库默认值不会破坏单元测试的精神。
I don't see what a database has to do with unit testing. If you are talking about integration testing that's whole other story but a unit test should never hit a database, so to answer your question: no, database default values do not break the spirit of unit testing.
如果数据库将成为应用程序之间的集成点,我会将默认值放入数据库中。每当我使用默认值时,我总是在实体的构造函数中将该属性设置为相同的值。所以从这个意义上说,我不明白为什么它会使单元测试无效。
I put default values in the database if it's going to be an integration point between applications. Whenever I do use a default value, I always set that property in the constructor of my entity to the same value. So in this sense, I don't see why it would invalidate unit testing.