Generator-jhipster: Why Entity-server subgenerator does not generate JUnit tests?

Created on 31 Oct 2019  路  7Comments  路  Source: jhipster/generator-jhipster

My question is why the entity server subgenerator does not have templates for simple JUnit tests on entity and repository classes

area

Most helpful comment

In my experience, 100% test coverage is a waste of time and doesn't improve the quality of the codebase. 70-80% is often "good enough". In my opinion, of course. :)

All 7 comments

I think it's because these classes are so simple, they don't need tests.

OK, but all methods of the entities are covered? For definition, a simple junit test (not integration) is made to test the methods class. I don't know if the generated server has 100 % of coverage

In my experience, 100% test coverage is a waste of time and doesn't improve the quality of the codebase. 70-80% is often "good enough". In my opinion, of course. :)

@amanganiello90 Hi, a simple remark: if you need test a "shallow" object like an entity or a DTO, you're only testing something without any logic. You should, however, focus your skills on testing logic (services, controllers, utils even, etc.).
A simple example, if your production code fails, then you're likely not gonna look at the entity but at the code "mimicking" the business logic that may have made the bug occur.
As Matt says, 100% test coverage is very often a waste of time because testing is also documenting and there's almost to no point in documenting simple classes that speak for themselves.

If I may, I suggest you read this quite interesting post by M. Fowler here. It may give you some context about why these classes aren't tested.

Thanks all, I know that article and I'm according to you. But maybe a repository test class that uses, for example, the search api and tests the entity result with all methods it's not bad, it is only a template to use for that, and the developer has an initial class to concentrate some scenarios only for the DAO layer.

Note that we do generate integration tests that should put you close to 100% coverage. IMO these IT have more value than UT would.

I think the answer from @cbornet is enough :

Note that we do generate integration tests that should put you close to 100% coverage. IMO these IT have more value than UT would.

So we can close this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lsadehaan picture lsadehaan  路  3Comments

SudharakaP picture SudharakaP  路  3Comments

dronavallisaikrishna picture dronavallisaikrishna  路  3Comments

sdoxsee picture sdoxsee  路  4Comments

Steven-Garcia picture Steven-Garcia  路  3Comments