Testing External Systems (TDD)
Joel Lau

Joel Lau @joellau

About: CRUD app extraordinaire

Location:
Singapore
Joined:
Oct 6, 2017

Testing External Systems (TDD)

Publish Date: Sep 12 '20
1 2

Software developed seldom works in isolation.

Connecting to external systems such as databases and consuming 3rd party APIs are integral parts of many products made today.

However, how do we write tests for these BEFORE we write code that integrates with these external systems?

Comments 2 total

  • Shani Fedida
    Shani FedidaSep 12, 2020

    I don't think the answer is different for TDD and writing tests in the end. You need a way to provide the dependencies: usually with fakes.

  • Brandin Chiu
    Brandin ChiuSep 12, 2020

    If you're writing unit tests for TDD, then you would be responsible for "mocking" these integrations as external services.

    Your unit tests are meant only to verify the internal integrity of your units or functions, not the external services.

    Usually this means making assumptions in your tests, and then testing for several things.

    For example, if you wanted to test how one of your methods interacts with an external service, you would want to "test" things like example responses based on those assumptions.

    Or you'd want to test how your method works if you were to simulate a failure from the api.

    stackoverflow.com/questions/266581...

Add comment