microservices-patterns / ftgo-application

Example code for the book Microservice patterns
Other
3.35k stars 1.29k forks source link

Persistence integration tests - no need to rise up mock servlet environment #112

Open asn25 opened 3 years ago

asn25 commented 3 years ago

Hello,

consider the following integration tests:

These tests are not setting any "webEnvironment" for @SpringBootTest what means that they use default WebEnvironment.MOCK, i.e. they are rising mock servlet environment.

On my opinion, it's not needed.

If webEnvironment is set to none (webEnvironment = SpringBootTest.WebEnvironment.NONE on @SpringBootTest), then tests run faster.

Below are some tests on my desktop (with precondition that mysql and dynamodbs services are up):

OrderJpaTest (with current configuration, i.e. WebEnvironment.MOCK) - 25 seconds OrderJpaTest (with WebEnvironment.NONE) - 20 seconds OrderHistoryDaoDynamoDbTest (with current configuration, i.e. WebEnvironment.MOCK) - 19 seconds OrderHistoryDaoDynamoDbTest (with WebEnvironment.NONE) - 15 seconds

asn25 commented 3 years ago

The same is with tests:

asn25 commented 3 years ago

Additionally, some issues with AccountingServiceCommandHandlerTest and RestaurantServiceLambdaConfigurationTest:

1) it seems they are integration tests, so should be moved from "tests" to "integration-tests"

2) RestaurantServiceLambdaConfigurationTest requires mysql up, otherwise it fails. Is it right? If yes, then it should have some "dockerComposeUp" task to startup its dependencies as integration test (the same way as OrderJpaTest does, f.e.). If no, then it shouldn't fail with mysql down.