microservices-patterns/ftgo-application

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

asn25 opened this issue · 2 comments

asn25 commented

Hello,

consider the following integration tests:

  • OrderJpaTest
  • RestaurantJpaTest
  • OrderHistoryDaoDynamoDbTest
    (and)
  • AccountingServiceCommandHandlerTest
  • RestaurantServiceLambdaConfigurationTest

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

The same is with tests:

  • AccountingServiceCommandHandlerTest
  • RestaurantServiceLambdaConfigurationTest
asn25 commented

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.