Search code examples
javatestingappiumstubby4j

Mock a physical web server while junit test running


I am searching for a simple framework which is able to mock JSON responses for specific URLs and therefore starts an in-memory server. E.g. the framework could start a node.js server or similar.

I need a physical server since the unit tests are running against an external application (using selenium) and this application has a dependency to a JSON interface. The application itself is iPhone-App running inside of simulator and communicates to a REST interface.

Is there an existing framework for this or what would be the best approach given that I need to execute the tests with jUnit.


Solution

  • You can start a stub server, given that you can configure the JSON URL in your client application.

    Have a look for example at:

    You can start these in your maven build during the pre-integrationtest phase and shut them down in post-integration test phase.