3 ms·
I once briefly experimented with the idea of a programmable fake server: 1. At startup, the fake server is tabula rasa 2. The "before" part of the API test sc
by hliyan 3y ago
I once briefly experimented with the idea of a programmable fake server:
1. At startup, the fake server is tabula rasa
2. The "before" part of the API test script will call specialised POST endpoints of the server to set up the fake endpoints (and the responses they are supposed to send) required for each test. The state is in-memory.
3. When the service that is the test target is started in test mode, all its dependencies point to the fake server.
4. The test script then runs the test on the service
This required zero application level mocking code. All the mocks were defined in the test scripts.
- sigg3 3y agoI think you could use pytest plugins `pytest-mock-server` or the `responses` plugin to achieve at least a partial coverage of your fake server idea.
- hliyan 3y agoI believe we explored this, but instead settled on a simple express-based Node.js server because that was the tech stack familiar to the team, and also due to the programmable nature of responses, a non-statically-typed language like JavaScript was preferred.