Executing tests in a pipeline

Developers should execute tests on their local machine before opening a merge request for their code. That way, they can be confident that any of the changes they made did not break any of the previous behaviors of their code. In theory, this provides the guarantee that all code merged to the master branch compiles and has all tests passing. In practice, there are many reasons why this is not the case. Some can be as follows:

  • Some tests might not be able to be run locally. They depend on confidential configuration values or are configured to run against a fully configured system. One or both of these are often the case for system tests. There are many situations where it is impossible to run system tests from the local system. Not all of these situations are necessarily desirable or insurmountable—but still, this is often the case.
  • Developers are only humans. They might forget to run the tests on their local machines after that one final tweak or are convinced that their changes did not break any existing behavior. Especially when delivering a bug fix under pressure, it can be tempting to skip running tests for the sake of speed.

To prevent these situations from allowing code that is not fully tested to propagate through the pipeline, it is recommended to have all tests also execute from within the pipeline. The following sections will show how to do this for unit tests and integration tests and for tests that are being run using other systems. First up are unit tests.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.221.163