Summary
Several test methods contain parameter/config validation logic that should be in fixtures instead. Per CLAUDE.md "Validate at Source" principle, validation should happen in fixtures where values originate, not in test methods.
Problem / Motivation
Test methods should focus on testing behavior, not validating configuration. When validation happens in test methods:
- Tests become harder to maintain
- Validation logic is duplicated across tests
- Skip/fail conditions are scattered instead of centralized
- It violates the "Validate at Source" pattern
Requirements
Violations Found
| Location |
Pattern |
What's Validated |
test_copyoffload_migration.py:209-210 |
pytest.skip() in test |
vSphere provider type |
test_copyoffload_migration.py:851-852 |
pytest.fail() in test |
rdm_lun_uuid config |
test_copyoffload_migration.py:1002-1020 |
pytest.fail() in test |
storage_vendor_product, datastore_id, secondary_datastore_id |
test_copyoffload_migration.py:1785-1796 |
pytest.fail() in test |
storage_vendor_product, datastore_id |
test_mtv_warm_migration.py:18-27 |
Module-level skipif |
Provider type for warm migration |
Issues Identified
- Redundant validation:
copyoffload_config fixture already validates storage_vendor_product and datastore_id, but tests check again
- Missing fixture validations:
rdm_lun_uuid and secondary_datastore_id should have dedicated fixtures
pytest.skip() and pytest.fail() inside test methods violate the "Validate at Source" pattern
Deliverables
Notes
- The
copyoffload_config fixture in tests/conftest.py already validates some fields - avoid duplicating this validation
- New fixtures should follow the existing pattern: validate at fixture level, raise
ValueError with clear message if invalid
- Use
@pytest.mark.skipif with helper functions for conditional test skipping
Summary
Several test methods contain parameter/config validation logic that should be in fixtures instead. Per CLAUDE.md "Validate at Source" principle, validation should happen in fixtures where values originate, not in test methods.
Problem / Motivation
Test methods should focus on testing behavior, not validating configuration. When validation happens in test methods:
Requirements
Violations Found
test_copyoffload_migration.py:209-210pytest.skip()in testtest_copyoffload_migration.py:851-852pytest.fail()in testrdm_lun_uuidconfigtest_copyoffload_migration.py:1002-1020pytest.fail()in teststorage_vendor_product,datastore_id,secondary_datastore_idtest_copyoffload_migration.py:1785-1796pytest.fail()in teststorage_vendor_product,datastore_idtest_mtv_warm_migration.py:18-27Issues Identified
copyoffload_configfixture already validatesstorage_vendor_productanddatastore_id, but tests check againrdm_lun_uuidandsecondary_datastore_idshould have dedicated fixturespytest.skip()andpytest.fail()inside test methods violate the "Validate at Source" patternDeliverables
rdm_lun_uuidvalidation fixture for RDM testssecondary_datastore_idvalidation fixture for multi-datastore tests@pytest.mark.skipifat class level instead ofpytest.skip()in test methodsNotes
copyoffload_configfixture intests/conftest.pyalready validates some fields - avoid duplicating this validationValueErrorwith clear message if invalid@pytest.mark.skipifwith helper functions for conditional test skipping