Skip to content

Commit

Permalink
Update contributing/testing-best-practices.md
Browse files Browse the repository at this point in the history
Co-authored-by: Agustin Bettati <[email protected]>
  • Loading branch information
lantoli and AgustinBettati authored Apr 11, 2024
1 parent 17ca19d commit d1870b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion contributing/testing-best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

## File structure

- Unit and Acceptances tests are in the same `_test.go` file. They are not in the same package as the code tests, e.g. `advancedcluster` tests are in `advancedcluster_test` package so coupling is minimized.
- Acceptances tests are in corresponding `_test.go` file as the resource or data source source file.
- General unit tests are in corresponding `_test.go` file as the resource or data source source file. If business logic is extracted into a separate file, unit testing for that logic will be including in its associated `_test.go` file (e.g. [state_transition_search_deployment_test.go](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/internal/service/searchdeployment/state_transition_search_deployment_test.go)).
- Tests are not in the same package as the code it tests, e.g. `advancedcluster` tests are in `advancedcluster_test` package so coupling is minimized.
- Migration tests are in `_migration_test.go` files.
- All resources need a `main_test.go` file to handle resource reuse lifecycle, e.g. [here](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/master/internal/service/advancedcluster/main_test.go).
- Helper methods must have their own tests, e.g. `common_advanced_cluster_test.go` has tests for `common_advanced_cluster.go`.
Expand Down

0 comments on commit d1870b4

Please sign in to comment.