默认情况下,单元测试和集成测试具有相同的名称
在 Grails 中,单元测试和集成测试使用完全相同的命名约定生成,因此,如果您正在测试名为 Foo
的域类,则两个测试都会使用名称 FooTests
生成。 ,在同一个包中。是否期望我应该进行单元测试或集成测试,但不能同时进行两者?人们是否将集成测试与单元测试放在不同的包中,或者重命名?解决这个问题的首选方法是什么?
顺便说一句,我修改了 grails/scripts/_GrailsCreateArtifacts.groovy 来更改类的生成方式,以便让它生成不同的名称(后缀属性的值全部更改)。当类位于名为“集成”的文件夹中时,我不喜欢在名称中包含一些表示“集成”的内容,但这至少避免了手动重命名。
createIntegrationTest = { Map args = [:] ->
def superClass = args["superClass"] ?: "GroovyTestCase"
createArtifact(name: args["name"], suffix: "${args['suffix']}IntTests",
type: "Tests", path: "test/integration", superClass: superClass)
}
In Grails the unit tests and integration tests get generated with exactly the same naming convention, so that if you are testing a domain class named Foo
both tests get generated with the name FooTests
, in the same package. Is there an expectation I should have either a unit test or an integration test, but not both? Do people put their integration tests in a different package from their unit tests, or rename one? What's the preferred way to get around this?
btw I hacked on grails/scripts/_GrailsCreateArtifacts.groovy to change how the classes are generated in order to get it to generate different names (the value for the suffix property is all that changed). I don't like having to include something that means 'integration' in the name when the class is in a folder called 'integration', but this at least avoids having to do a manual rename.
createIntegrationTest = { Map args = [:] ->
def superClass = args["superClass"] ?: "GroovyTestCase"
createArtifact(name: args["name"], suffix: "${args['suffix']}IntTests",
type: "Tests", path: "test/integration", superClass: superClass)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为给他们一个不同的名字是正确的选择。
或者
I think giving them a different name is the right choice.
or