wazuh / wazuh-qa

Wazuh - Quality Assurance
GNU General Public License v2.0
60 stars 30 forks source link

DTT2 - Testing Module. Replace the use of assert statements with explicit exceptions in the helper function. #5294

Open mhamra opened 1 week ago

mhamra commented 1 week ago
Target version Related issue Related PR/dev branch
4.9.0 4495-dtt1-release

The testing module raises exceptions using assert statements in helper functions. While using assert statements in tests is okay, checking and raising explicit exceptions in the library is better.

For example, in this method, I suggest raising a custom exception.

https://github.com/wazuh/wazuh-qa/blob/e71e39aea2caeb0dceab9645fe4f9343152a8a83/deployability/modules/testing/tests/helpers/agent.py#L92-L106

Creating custom testing module exceptions is a better solution to handle known error conditions. The pytest tests will receive these exceptions, making the test fail.