-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
refactor entity's integration test class #10686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor entity's integration test class #10686
Conversation
generators/entity-server/files.js
Outdated
] | ||
}, | ||
{ | ||
condition: generator => generator.dto === 'mapstruct' && (generator.databaseType === 'sql' || generator.databaseType === 'mongodb' || generator.databaseType === 'couchbase'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this condition:
The fromId
method of the mapper is generated only when DB are sql or mongodb or couchbase, but the test is only generated when the DB is sql...
23d21da
to
676e15b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This was something I wanted to do too.
I think this is a first step, tests can be refined/refactored later (e.g. split the equalsVerifier() method in multiple tests).
FYI there are compilation failures in MapperTest, related to UUID.
generators/entity-server/files.js
Outdated
templates: [ | ||
{ | ||
file: 'package/domain/EntityTest.java', | ||
renameTo: generator => `${generator.packageFolder}/domain/${generator.asEntity(generator.entityClass)}Test.java` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renameTo: generator => `${generator.packageFolder}/domain/${generator.asEntity(generator.entityClass)}Test.java` | |
renameTo: generator => `${generator.packageFolder}/domain/${generator.entityClass}Test.java` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the remark, I took it in account in my last commit.
I fixed the missing import to UUID in MapperTest too :)
cc0f403
to
8b7764d
Compare
move tests to appropriate test classes.
8b7764d
to
03abdc1
Compare
Thanks @stonedMoose and congrats for your first contribution! |
Thanks a lot ! |
I use Jhipster for a few months now, and I was surprised to find some tests in EntityResourceIT which does not belong here in my opinion:
The first one, is the
fromId
test which appear when mapstruct is involved. This test is not in anyway an integration test and it does not test the Resource but the Mapper. So I propose to move it to a class named EntityMapperTestThe last two tests which do not belong to EntityResourceIT are the
equalsVerifier
. These tests ensure that theequals
method on Entity or DTO works as intended, so they should be respectively inEntityTest
andEntityDTOTest
.It's not a big improvment and it will not change the face of the earth, but it make sense to me, I hope it will make sense to you too.
Plus it will lower the amount of integration test and increase the number of unit test in the generated apps.