Friday, August 28, 2015

Integration tests in SpringBoot without external dependencies

Target - test all layers of SpringBoot REST application in isolation from external components.

Complexity - typical application uses database and makes calls to remote services.

Solutions:

a) Use spring-test support for integration tests. It actually starts whole app for you on random port. At the same time, all components of app can be wired into test for additional manipulations.

b) Use RestAssured to make calls to our application

c) Use RestTemplate to make remote calls and MockServer from spring-test to mock them

d) Use in-memory database. HSQLDB does the simulating job pretty well.

e) Use separate Spring profile to tweak app configuration


Here is a small example putting it all together:


2 comments:

  1. Hello Aleksandr,
    The informative Article on Integration tests in SpringBoot without external dependencies is good. It gives detailed information about it .Thanks for Sharing the information unit testing and integration testing. Software Testing Services

    ReplyDelete
  2. Amplework Software Pvt. Ltd. offer flexible models to hire expert Swift app developers and programmers on hourly, part-time, or full-time contract basis at affordable cost.



    Product Design
    MVP Development
    DevOps Solutions
    Mobile Application Development
    Voice/Alexa App Development
    IoT App Development

    ReplyDelete