Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Integration Testing | Testing in Development
Java JUnit Library. Types of Testing

Integration TestingIntegration Testing

In the previous chapter, we discussed unit testing, where we tested individual modules. However, the program may still not work correctly if we only tested individual modules in isolation. Modules constantly interact with each other; one module is used in another, the second in the third, and so on. Such interactions between modules also need to be tested, and this level of testing is called integration testing.

For example, we have an Engine class with its fields and methods, as well as a Car class in which an instance of the engine class is created using composition. In other words, the methods of the car class involve an object of the engine class. Integration occurs, which means we need to test whether this integration is done correctly.

java

Engine.java

java

Car.java

As you can see, we have 2 classes ( you can switch between files above ), each with its own methods. In the Car class, you can see an instance of the Engine class being created. This is called composition. Inside the methods of the Car class, we use the methods of the Engine class, which means that if something goes wrong in the Engine class, the methods in the Car class will also break. So, here is the algorithm of what we need to do:

  • First, we need to test all the methods of the Engine class in isolation;
  • Then, we need to test the methods of the Car class;
  • This testing will be integration testing since the methods of the Car class use the methods of the Engine class;
  • If the integration testing is successful, we perform unit testing of the Car class. (such testing may not be needed at all if the Car class does not have any methods that don't use an instance of the Engine class.)

Within our example, we will only need integration testing to avoid overwhelming you with unnecessary steps. The goal of this chapter is to demonstrate integration testing.

I've highlighted the code blocks for you where testing is performed with comments. As you can see, the test itself is simple and straightforward. There's nothing complex in such testing, and it shows that different modules interact correctly with each other.

A demonstration of a runnable example:

java

main.java

Thus, we've performed a basic integration test, demonstrating that these methods work correctly together. Integration testing was successful, and the methods have been tested successfully. Great! We'll delve deeper into integration testing in the third section of this course.

Everything was clear?

Section 1. Chapter 5
course content

Course Content

Java JUnit Library. Types of Testing

Integration TestingIntegration Testing

In the previous chapter, we discussed unit testing, where we tested individual modules. However, the program may still not work correctly if we only tested individual modules in isolation. Modules constantly interact with each other; one module is used in another, the second in the third, and so on. Such interactions between modules also need to be tested, and this level of testing is called integration testing.

For example, we have an Engine class with its fields and methods, as well as a Car class in which an instance of the engine class is created using composition. In other words, the methods of the car class involve an object of the engine class. Integration occurs, which means we need to test whether this integration is done correctly.

java

Engine.java

java

Car.java

As you can see, we have 2 classes ( you can switch between files above ), each with its own methods. In the Car class, you can see an instance of the Engine class being created. This is called composition. Inside the methods of the Car class, we use the methods of the Engine class, which means that if something goes wrong in the Engine class, the methods in the Car class will also break. So, here is the algorithm of what we need to do:

  • First, we need to test all the methods of the Engine class in isolation;
  • Then, we need to test the methods of the Car class;
  • This testing will be integration testing since the methods of the Car class use the methods of the Engine class;
  • If the integration testing is successful, we perform unit testing of the Car class. (such testing may not be needed at all if the Car class does not have any methods that don't use an instance of the Engine class.)

Within our example, we will only need integration testing to avoid overwhelming you with unnecessary steps. The goal of this chapter is to demonstrate integration testing.

I've highlighted the code blocks for you where testing is performed with comments. As you can see, the test itself is simple and straightforward. There's nothing complex in such testing, and it shows that different modules interact correctly with each other.

A demonstration of a runnable example:

java

main.java

Thus, we've performed a basic integration test, demonstrating that these methods work correctly together. Integration testing was successful, and the methods have been tested successfully. Great! We'll delve deeper into integration testing in the third section of this course.

Everything was clear?

Section 1. Chapter 5
some-alt