TCS Backend test Spike findings:

Unit test: At a high-level, unit testing refers to the practice of testing certain functions and areas – or units – of our code. This gives us the ability to verify that our functions work as expected. That is to say that for any function and given a set of inputs, we can determine if the function is returning the proper values and will gracefully handle failures during the course of execution should invalid input be provided.

The scope of unit testing is internal to service and in terms of volume tests, they should be largest in number.

Type of test we have in TCS:

1. unit test: In the unit test, we are mocking each layer of service including controller and logic layer and making a real request from the logic layer to the database and writing a separate test for each layer.

Integration test: An integration test usually tests the interactions between the microservice and external services, such as another microservice or datastore. Integration Testing is performed to verify the interactions between the modules of a software system. It also verifies a software system's coexistence with others and tests the interface between modules of the software application.

2. Integration test (type 1 ): In an integration test, we are again mocking all layer of the service including controller, logic and database layer and expecting mocked output. All this mocking is happening in a single test.

2. Integration test (type 2 ): In this type of integration test we are making a real request to all service layer of the service and expecting the real response from each layer of service in a single test.

Contract testing: Contract testing is a way to ensure that services (such as an API provider and a client) can communicate with each other. Contract testing is immediately applicable anywhere where you have two services that need to communicate - such as an API client and a web front-end. Although a single client and a single service is a common use case. A contract is between a consumer (for example, a client that wants to receive some data) and a provider (for example, an API on a server that provides the data with the client needs.
Current status: Pact POC already in place. Devs have started to implement the contract test for BE services.

Our Findings: In BE TCS test we are referring some of the unit tests as an integration test which needs to renamed. We have to find the same approach to write test instead of following different approaches as It will not add any value. We have an agreed unit test strategy in place and integration test strategy needs to be discussed.

We have also identified that testing type unit and contract test, integration test are required for BE services.