Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit and integration tests get the same names by default

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)
}
like image 268
Nathan Hughes Avatar asked Oct 09 '22 16:10

Nathan Hughes


1 Answers

I think giving them a different name is the right choice.

*IntTests 

or

*IntegrationTests
like image 121
Jay Prall Avatar answered Oct 19 '22 00:10

Jay Prall