Unit, Integration & Functional Testing

Unit Testing

Unit test tests single unit of code without communicating with the external dependencies i.e. file system, network or database.

It should run as quickly as possible so that you can run hundreds of unit tests in few seconds before pushing the source code into the repository.

Integration Testing

Integration tests are used to verify that various components of your system works good together.

These are also used to make sure that application works well with external dependencies like file system, network and database.

Integration tests are difficult to setup and are slower as compared to unit tests as they interact with external dependencies.
Integration tests

Functional Testing

Integration tests are written from the perspective of developer to make sure that various components of application works correctly together whereas functional tests are written from the perspective of application users to make sure that application id built according to the requirements.

Functional tests not only require infrastructure setup but also they need UI as well to test the application.

What should be tested?

You should write tests for your methods which contain conditional logic (like if/else or switch statements).

If your code has error conditions then write at least two tests one for happy path means with which test should pass and the other for the sad path to fail your test.

Comments
Share it