Ensure tests thoroughly validate functionality through comprehensive assertions. When writing tests: 1. Assert all relevant aspects of the expected behavior, not just presence/absence or simple success/failure
Ensure tests thoroughly validate functionality through comprehensive assertions. When writing tests:
Example:
# Incomplete test - only checks summary counts
def test_resource_skips_incomplete():
report = Runner().run(root_folder=test_files_dir, runner_filter=RunnerFilter(checks=[]))
summary = report.get_summary()
self.assertEqual(summary["skipped"], 3) # โ Missing specific assertions
# Better test - verifies specific resources and their properties
def test_resource_skips_thorough():
report = Runner().run(root_folder=test_files_dir, runner_filter=RunnerFilter(checks=[]))
# Assert overall summary
summary = report.get_summary()
self.assertEqual(summary["skipped"], 3)
# Assert specific resources and their skip counts
skipped_resources = report.get_skipped_resources()
self.assertEqual(len(skipped_resources["default"]), 1)
self.assertEqual(len(skipped_resources["skip_invalid"]), 1)
self.assertEqual(len(skipped_resources["skip_more_than_one"]), 2) # โ
Thorough validation
When implementing new functionality, always add corresponding tests that validate the specific behavior, not just general outcomes. For critical logic, create dedicated unit tests even if the component is tested indirectly elsewhere.
Enter the URL of a public GitHub repository