Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Developer guideline to write unit/integration tests in CAPA repo #3289

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/book/src/development/conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,25 @@ use
```

And then within the code you can check the length or range over the slice.

## Tests

There are three types of tests written for CAPA controllers in this repo:
* Unit tests
* Integration tests
* E2E tests

In these tests, we use [fakeclient](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/client/fake), [envtest](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest) and [gomock](https://pkg.go.dev/github.com/golang/mock/gomock) libraries based on the requirements of individual test types.

If any new unit, integration or E2E tests has to be added in this repo,we should follow the below conventions.

Ankitasw marked this conversation as resolved.
Show resolved Hide resolved
### Unit tests
These tests are meant to verify the functions inside the same controller file where we perform sanity checks, functionality checks etc.
These tests go into the file with suffix *_unit_test.go.
richardcase marked this conversation as resolved.
Show resolved Hide resolved

### Integration tests
These tests are meant to verify the overall flow of the reconcile calls in the controllers to test the flows for all the services/subcomponents of controllers as a whole.
These tests go into the file with suffix *_test.go.

### E2E tests
These tests are meant to verify the proper functioning of a CAPA cluster in an environment that resembles a real production environment. For details, refer [here](https://cluster-api-aws.sigs.k8s.io/development/e2e.html).