The main focus of unit tests is to focus on small units in isolation. But only focusing on the small units does not touch all the code. So this blog post clarifies the difference between unit and integration tests.
Unit Tests should run fast, since the tests should be executed after each change and provide instant feedback. So unit tests should not contain too much DOM manipulation, reliance on timed behavior or contain any network activity.
Therefore, unit tests should focus on the smallest piece of functionality and be decoupled from unreliable or slow dependencies. With unit tests you focus on a specific responsibility, e.g. formatting, error handling, data transformations or validations. In the last blog post, I showed how to start with Test Driven Development. Such kinds of unit tests are not specific to SAPUI5.
There are different kinds of Integration Tests: One kind of integration tests is a so called Smoke or System Test that tests the complete stack including the backend. Then there are Integration Tests without dependencies to fragile components. Non-isolated tests are fragile and result often in a lot of maintenance effort. This blog post series first concentrates on unit tests and isolated integration tests with QUnit. You can test your application against the SAPUI5 view and isolate your application, so that no synchronization with the backend is done. Compared to unit tests, you do not isolate from the DOM and the tests are, therefore, slower. With such kind of tests, you test the integration of the single modules, the event handling, user interaction, styling, cross-browser issues or binding of an application.
So, first start with TDD for small modules and stay tuned (make a bookmark to or like the overview blog post). In the next blog posts I propose some patterns how to increase the testability for integration tests.
This blog post is part of a series, see overview blog post: