ansible-collections / amazon.aws

Ansible Collection for Amazon AWS
GNU General Public License v3.0
309 stars 341 forks source link

Enhancement idea: Use unit tests whenever possible instead of integration tests #1982

Open alinabuzachis opened 9 months ago

alinabuzachis commented 9 months ago

Summary

We have many integration tests in the amazon.aws repository, even for very small plugin features. Integration testing is slow, and the need to create new resources to test even some small features results in a lot of overhead, which makes integration testing even slower. Some features can be easily tested without integration testing by simply writing some units. The idea would be to identify these cases and, instead of covering them with integration tests, add some unit tests. I would probably consider integration tests only for the main operations (create, idempotency checks, update, delete) with some relevant plugin options, and unit tests when testing the other functionalities.

Issue Type

Feature Idea

Component Name

Several

Additional Information

No response

Code of Conduct

gravesm commented 8 months ago

I would add that we should also try to come up with some guidelines for when to use unit tests and when to use integration tests, and document that.

tremble commented 8 months ago

The problem I have with saying "whenever possible", is that historically a lot of our code hasn't been written in such a way that unit tests are "useful". We probably need to take a step back and think about how we recommend modules are written, such that writing unit tests doesn't involve placebo recordings. (And preferably doesn't necessitate mocking up AnsibleModule and Boto3 Client's)