Prompt
Tests should be designed to be independent and avoid coupling to implementation details. Use public interfaces rather than accessing internal state, prefer mocked or fake data over external dependencies, and keep tests general rather than tightly coupled to specific implementations.
Key principles:
- Avoid accessing internal state like
raw_pointsin test cases - use proper public interfaces likehandle_loginstead - Use made-up or mocked data rather than requiring external handlers when the test doesn’t specifically need to test that integration
- Design tests to know as little as possible about specific implementations (e.g., car brands) to keep them general and maintainable
Example of good practice:
# Instead of accessing internal state:
est.raw_points["lat_active"].append(True)
# Use the public interface:
est.handle_log(log_message)
This approach makes tests more maintainable, less brittle to refactoring, and easier to understand by focusing on the component’s public contract rather than its internal implementation.