jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

Never overwrite unit or integration tests automatically #23211

Closed Semo closed 1 year ago

Semo commented 1 year ago

Stop overwriting unit tests or integration tests when e.g. running a JDL with jhipster generator. Even if the user selects "force" option, just don't allow overwriting tests.

Motivation

After a JDL file has been updated and executed in the jhipster generator, there will be a number of changes in the entire project. It has turned out, that when a file needs to be overwritten, it is easier to let the generator do its job rather than individually agreeing or denying. Otherwise, problems arise when rejecting the change, if you accidentally agree when you would have been better off rejecting it. This problem arises, when you have a large number of files that need to be accepted or rejected one at a time, making it easier to have everything overwritten.

But the fundamental problem with this is that all unit and integration tests are then mercilessly overwritten.

This is a very bad strategy IMHO, since developers don't have a chance to check the completion of customer tasks afterwards. Unless developers go to the repository to correct the files manually, which is laborious and very time-consuming.

That's why I suggest implementing a protection mechanism that automatically prevents the overwriting of units or integration tests as long as the user does not specify a flag/switch/whatever in the command.

Why is it important?

Having unit and integration tests is the only way to find out, if the frontend/backend will fulfil already solved issues/feature requests of an application.

mraible commented 1 year ago

We recommend committing your project to Git before running any JHipster commands. That way, you can always roll back if files are overwritten or deleted by mistake.

mshima commented 1 year ago

We have .yo-resolve for that. echo src/test/java/** >> .yo-resolve

More tips https://www.jhipster.tech/tips/035_tip_combine_generation_and_custom_code.html