generator-jhipster: Generated java integration tests have incorrect suffix 'IntTest'

Overview of the issue

Maven plugin dedicated to integration tests (maven-failsafe-plugin includes by default tests with IT prefix/suffix, not IntTest prefix/suffix : https://maven.apache.org/surefire/maven-failsafe-plugin/examples/inclusion-exclusion.html

Motivation for or Use Case

Currently integration tests generated by JHipster are run during test phase by maven-surefire-plugin whereas they should not be run.

Reproduce the error
  • Generates a new application from .yo-rc.json.
  • Run mvn test
  • Output will contains:

[INFO] Running com.mycompany.myapp.web.rest.LogsResourceIntTest

Related issues

#498, #2663

Suggest a Fix
JHipster Version(s)

5.7.0

JHipster configuration

{ “generator-jhipster”: { “promptValues”: { “packageName”: “com.mycompany.myapp”, “nativeLanguage”: “en” }, “jhipsterVersion”: “5.7.0”, “applicationType”: “microservice”, “baseName”: “jhipster”, “packageName”: “com.mycompany.myapp”, “packageFolder”: “com/mycompany/myapp”, “serverPort”: “8081”, “authenticationType”: “jwt”, “cacheProvider”: “hazelcast”, “enableHibernateCache”: true, “websocket”: false, “databaseType”: “sql”, “devDatabaseType”: “h2Disk”, “prodDatabaseType”: “mysql”, “searchEngine”: false, “messageBroker”: false, “serviceDiscoveryType”: “eureka”, “buildTool”: “maven”, “enableSwaggerCodegen”: false, “jwtSecretKey”: “N2E3YmM1N2RiOTk3MmFiYWQ3ZGZmNGRjY2U4Mzk2ZWYwNTczMzEyZjdiYjNkYmU5NWY4YmQyZThhNzNmYWQwZjdjMTlhODg4MDJmOTE5ODBhNzY2OWViNWEwMDRlMzM5MTkyYTdjMzNmNDUzMzMwNDg4NDRjNWE5Njg1ZDAxOTc=”, “testFrameworks”: [], “jhiPrefix”: “jhi”, “otherModules”: [], “enableTranslation”: true, “clientPackageManager”: “npm”, “nativeLanguage”: “en”, “languages”: [ “en” ], “skipClient”: true, “skipUserManagement”: true } }

  • Checking this box is mandatory (this is just to show you read everything)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 20 (17 by maintainers)

Commits related to this issue

Most upvoted comments

Both #9337 (maven) and #9328 (gradle) have been merged, so I am closing this.

Hello,

verify being after the package phase is really useful if you test with some others tools (https://github.com/palantir/docker-compose-rule in a multi module maven project for example).

Purely subjectively, I’d argue that the “slow” feedback loop is in fact “much faster”. I usually make a large part of the coverage with standard unit tests and fallback to Spring when we really need it. Instantiating a full Spring app is reaaaaally slow for unit tests.

Jhipster are not exactly integration test in the sens that they do not need an environment to integrate with

They literally launch a complete Cassandra container.

I created PR https://github.com/jhipster/generator-jhipster/pull/9174 to separate unit from integration test in maven project @atomfrede can you check for gradle?

I have something working, awaiting some feedback before opening the PR

Here is a task lists gathered from #6131, #6149: (I might have missed something)

  • Prefix Integration Tests by IT
  • Use the maven failsafe plugin instead of the surefire one (so launching them during the integration-test phase)
  • Put them in a src/it/java|ts|resource folder & use the build-helper-maven-plugin to add a new source folder within IDEs

might break some mvn plugins ? (https://github.com/jhipster/generator-jhipster/issues/6131#issuecomment-315694573) failsafe’s default value looks like Integration Tests should be in src/test/java, but I’m open to change if needed

  • generate separate coverage for UT/IT

is this feature really needed ?

  • Migrate existing integration test

no idea on how to do this ¯\(ツ)

Yes for me the discussion on #6131 is still accurate, and I still haven’t any Java developer separate unit tests and integration tests (and that’s bad, and I know it, but that’s the way people work).

Now we’ve always tried to provide “best practices” and push new and interesting stuff, so I’m totally in favor of changing this, I just have 2 issues with this:

  • We need to check if all common IDEs support this correctly, as well as Sonar
  • This is a major breaking change for everyone, so I wouldn’t do it now but on our next major release

Thanks @Allsimon !

I don’t necessary agree with the separate source/resource folder. It’s not standard. But I don’t have the final word 😃

Regarding separate coverage for UT/IT I don’t understand why it’s needed. On the contrary, we should make sure coverage is consolidated.

And for migrating existing IT, I’m not sure… maybe take a look to https://github.com/jhipster/generator-jhipster/blob/master/generators/app/index.js#L452 and cleanup.js to see if it can be used.