Skip to content

Commit 6ab9562

Browse files
authored
Merge pull request #3289 from Ankitasw/dev-doc-update
docs: Developer guideline to write unit/integration tests in CAPA repo
2 parents 711b70d + 5c5ed28 commit 6ab9562

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/book/src/development/conventions.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,25 @@ use
3636
```
3737

3838
And then within the code you can check the length or range over the slice.
39+
40+
## Tests
41+
42+
There are three types of tests written for CAPA controllers in this repo:
43+
* Unit tests
44+
* Integration tests
45+
* E2E tests
46+
47+
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.
48+
49+
If any new unit, integration or E2E tests has to be added in this repo,we should follow the below conventions.
50+
51+
### Unit tests
52+
These tests are meant to verify the functions inside the same controller file where we perform sanity checks, functionality checks etc.
53+
These tests go into the file with suffix *_unit_test.go.
54+
55+
### Integration tests
56+
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.
57+
These tests go into the file with suffix *_test.go.
58+
59+
### E2E tests
60+
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).

0 commit comments

Comments
 (0)