Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 2.06 KB

File metadata and controls

46 lines (32 loc) · 2.06 KB

Shared Library testing

Concept for how to test the functionality of this shared library.

testing

There are different test types used for testing at different levels.

  • unit tests (JUnit 4)
    • single component
    • internal functions of the library
  • unit tests (JenkinsPipelineUnit)
    • exposed library functionality (vars directory and classes)
  • integration tests (Jenkins Unit Test Harness)
    • several components working together
    • functionality using Jenkins dependencies only
    • functionality using internal dependencies only
  • end-to-end tests (on real jenkins)
    • external services needed (K8S, Registries, ...)
    • complex test setup

INFO: Usage of the spock test framework is deprecated.

unit tests

Groovy functions and classes are tested with unit tests. Dependencies are mocked. They are located in test/groovy

Function unit testing is done with BasePipelineTest's from JenkinsPipelineUnit. The test files are named *Test.groovy

Eg. test/groovy/vars for scripts in vars

Whole scripts are tested with a pipeline file. Mostly green-path testing is enough. Edge cases are tested in spec classes. The test files are named *PipelineTest.groovy

test execution

Tests can be executed with ./gradlew clean test

further documentation