user5326354
user5326354

Reputation:

How to write integration tests?

My team develops a Web API 2 application using Entity framework 6 ORM.

Our application acts as an email, and it's main purpose and action is to send a letter from one client to another.

Since it's the application's main purpose, we'd all like to have an integration test that will assure us that a letter is sent correctly. That is because we don't want to accidentally insert code that will break that.

When sending a letter the main actions that happen and that we'd like to test are-

I'm asking this because I'm clueless about how to approach this, yet I really want that sort of test which I can rely on.

How should a test for this be set? Where do I start? How to achieve an actual letter sending through a test and make sure it works?

It doesn't have to be an end to end test.

Thanks

Edit:

I don't mind tests to take long time, they can be run at night, but I want them to verify as much as possible that the application main parts are working as expected.

Upvotes: 1

Views: 1227

Answers (1)

Pedro G. Dias
Pedro G. Dias

Reputation: 3222

I would set up multiple, non-actual code tests to verify your logic:

  1. Reception of the letter, and it's logic
  2. Verify that the save method to the database is invoked only when it should
  3. Verify the serialization/deserialization bits of code
  4. Verify that the destination picker module is working correctly.

Once you have these "non-invoking" tests, you know that all the bits of your system are working correctly individually. You can then set up a unit-test with some kind of marking (i.e. TestCategory("SUPERSLOW")) and then have that run manually against a mocked set of recipients for verification during integration test runs, NOT as part of your CI.

Keywords here are:

  • SOLID principles
  • Separation of Concerns
  • Mocking
  • Continuous Integration
  • Inversion of Control

Upvotes: 1

Related Questions