Skip to main content

Package test

This package acts as a wrapper over Golang's testing module.

Interfaces​

Suite​

Interface​

type TestingSuite interface {
Env() *env.Environment
SetEnv(environment *env.Environment)
SetT(t *testing.T)
T() *testing.T
SetupSuite() []Option
}

Functions​

Run()​

Parameters​

  • t *testing.T
  • suite TestingSuite
  • extraOptions ...Option

Description​

This is the starting point for a gosoline integration test. This performs the following steps:

  1. Uses reflection to find all test cases declared by a given TestSuite.
  2. Applies each of the extraOptions.
  3. Creates a kernel with whatever modules or APIs were declared in the SetupSuite and SetupApiDefinitions.
  4. Runs the tests.

Configuration​

Test components are docker container like wiremock or localstack which support you in your integration tests to mock your applications infrastructure.

Container expiry​

All test containers are configured with an automatic expiry time to prevent orphaned containers if tests crash. The default is 5m (5 minutes). This is configured globally via test.container_manager.expire_after and applies to all test containers. You can also use suite.WithContainerExpireAfter() to set it programmatically.

Image configuration​

The used image for a component can be configured on a global and on a per component level. The following configuration snipped shows a config for two wiremock components. mockA gets the image configuration from the global level which is configured via the key test.defaults.images.wiremock and mockB has local configuration. With this, mockA gets tag 3.4.0 and mockB gets 3.3.0.

test:
container_manager:
expire_after: 5m # applies to all containers
defaults:
images:
wiremock:
repository: wiremock/wiremock
tag: 3.4.0
components:
wiremock:
mockA: {}
mockB:
image:
repository: wiremock/wiremock
tag: 3.3.0