Skip to content
RED SAGSkills
easyBackend Developer interview question

How would you test a new POST /orders endpoint? Which kinds of tests would you write?

What the interviewer wants to hear

  • Unit tests for business logic such as price calculation and validation
  • Integration tests with a real database, for example in Docker
  • API tests that check status codes, response body and errors
  • Cover edge cases: invalid input, missing auth, duplicates, out of stock
  • Mock external services and run tests in CI

Model answer

I would follow the testing pyramid. First, unit tests for the pure logic, like calculating totals, applying discounts and validating input, with dependencies replaced by fakes. Next, integration tests that run the repository code against a real PostgreSQL in a container, so I know the SQL and constraints work. Then a few API tests that send real HTTP requests to the app and check the full behaviour: 201 with the new order and a Location header for valid input, 400 with clear field errors for bad input, 401 without a token, 403 for another user's resources, and 409 when stock runs out. External services like payments would be mocked or pointed at a sandbox. I make tests independent, with fresh data for each, and run them all in CI on every pull request so bugs are caught before merging.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy Backend Developer questions