Prompt
Write tests that verify actual system behavior rather than implementation details by minimizing mock usage and focusing on real interactions. Excessive mocking can lead to brittle tests that pass even when core functionality is broken.
Key guidelines:
- Prefer real implementations over mocks when practical
- When mocking is necessary, mock at system boundaries rather than internal components
- Use built-in test helpers (e.g. @override_options) instead of mocking configuration
- Break complex test scenarios into separate focused test methods
Example - Instead of:
@patch("sentry.api.endpoints.seer_rpc.integration_service.get_organization_integrations")
@patch("sentry.api.endpoints.seer_rpc.options.get")
def test_complex_scenario(self, mock_options, mock_integrations):
mock_integrations.return_value = []
mock_options.return_value = []
# Test implementation
Prefer:
@override_options({"feature.flag": True})
def test_complex_scenario(self):
# Create real integration
integration = self.create_integration(
organization=self.organization,
provider="github"
)
# Test actual behavior
This approach produces more reliable tests that better verify system correctness and are easier to maintain.