Unit, Integration and System Testing Strategies for Software Applications
By: Code Fiction
Tags: Software Development, Testing, Backend, Test Driven Development, Backend Development

Overview

Software testing is defined as an activity to check whether the actual results match the expected result and to ensure that the software system is bug free.

Testing your software is a very important aspect of software development and can largely dictate the fate of an application or web service by catching possible dangerous bugs early on.

There are mainly three types of software testing that we’ll be approaching in this article :

Unit testing

Integration testing

System testing

Although each test may follow a different strategy to be executed, their main purposes are similar (assert that the application is working properly) and there are some guidelines that we can follow to effectively work with software testing.

We will cover a little bit of the tests here, and will actually implement them in the next articles.

Unit testing

Used to test individual code components of an application in order to assert that each unit is working properly.

In Java, a unit is usually referred to as a single class or method.

Guidelines to follow when developing unit testing an application are :

Fail if the code is broken

Maintainability and Readability

Each unit test must verify a single component

Components don’t depend on any outside factors

Some benefits when applying unit tests :

Confidence increase when changing and maintaining code. If good unit tests are run every time any code is changed, defects or bugs introduced by those changes will be easier to catch.

When unit testing your application, you need to make sure your code is modular. This means an increase in reusability.

Faster development. All the time saved by proving the safety of your application will add up in the end.

Unit tests are implemented first because they are easier to write and quicker to execute due to its simplicity.

Two of the most popular frameworks used in the Java ecossystem for unit testing method level application are JUnit and TestNG, they are commonly used in conjuncture with a mocking framework like EasyMock, Mockito or JMockit.

Integration testing

Used to check if your application is functioning as a whole, rather than testing individual components, it aims to test across components like code, database and web servers.

Some issues that are able to pop when integration testing your application are components wiring, database bugs, network access, etc.

When thinking about guidelines to follow when working with integration testing, one should always aim to prove that the major parts of a system work well together.

There are no mock objects in integration testing, only real components such as your repository, database, UI, etc.

Some approaches when applying integration tests to your application :

Big bang : Involves testing components after each component has been finished

Top-down : Categorizes the software by its abstract level, the more abstract a component is the higher level it has. Top level units are tested first and lower level units are tested step by step after that. This approach is taken when the development is also made from top-to-down

Bottom-up : Bottom level units are tested first and upper-level units step by step after that. Usually implemented when bottom-up development approach is also followed

Sandwich : Combination of top-down and bottom-up

System testing

Usually accomplished by executing one or more of the following tests :

Functionality testing : Proves that all software functionalities are working correctly by the standards of the requirement

Performance testing : Proves how efficient the software is by testing its effectiveness against the average time of execution. Load tests and stress tests are a big part of performance testing

Security & Portability : Done when the software is expected to work in between various platforms and accessed by a number of people

It can be done manually by a person or automatically.

Endnotes

When testing software, it’s important to think about the goal of testing. The development team should assure that the system won’t break when using bad data or when unexpected actions are performed.

Good testing suites should try to break your application and help understand its limits.

Authorship

This article was originally written by Gabriel Pulga and Gibran Pulga on codefiction.net and can also be found here.