Skip to content

Conversation

stonedMoose
Copy link

@stonedMoose stonedMoose commented Oct 26, 2019

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 fromIdtest 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 EntityMapperTest

  • The last two tests which do not belong to EntityResourceIT are the equalsVerifier. These tests ensure that the equalsmethod on Entity or DTO works as intended, so they should be respectively in EntityTest and EntityDTOTest.

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.

  • Travis tests are green
  • Tests are added where necessary
  • Documentation is added/updated where necessary
  • Coding Rules & Commit Guidelines as per our CONTRIBUTING.md document are followed

]
},
{
condition: generator => generator.dto === 'mapstruct' && (generator.databaseType === 'sql' || generator.databaseType === 'mongodb' || generator.databaseType === 'couchbase'),
Copy link
Author

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 fromIdmethod 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...

@stonedMoose stonedMoose force-pushed the move-some-integration-test-to-appropriate-unit-test-classes branch 4 times, most recently from 23d21da to 676e15b Compare October 26, 2019 15:26
Copy link
Contributor

@murdos murdos left a 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.

templates: [
{
file: 'package/domain/EntityTest.java',
renameTo: generator => `${generator.packageFolder}/domain/${generator.asEntity(generator.entityClass)}Test.java`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
renameTo: generator => `${generator.packageFolder}/domain/${generator.asEntity(generator.entityClass)}Test.java`
renameTo: generator => `${generator.packageFolder}/domain/${generator.entityClass}Test.java`

Copy link
Author

@stonedMoose stonedMoose Oct 26, 2019

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 :)

@stonedMoose stonedMoose force-pushed the move-some-integration-test-to-appropriate-unit-test-classes branch from cc0f403 to 8b7764d Compare October 26, 2019 20:01
move tests to appropriate test classes.
@stonedMoose stonedMoose force-pushed the move-some-integration-test-to-appropriate-unit-test-classes branch from 8b7764d to 03abdc1 Compare October 26, 2019 21:03
@murdos murdos merged commit c5f919e into jhipster:master Oct 27, 2019
@murdos
Copy link
Contributor

murdos commented Oct 27, 2019

Thanks @stonedMoose and congrats for your first contribution!

@pascalgrimaud
Copy link
Contributor

Thanks a lot !
Congrats for your 1st contribution @stonedMoose !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants