We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Testing Hack with Hammock - Riya Dashoriya - PHP UK 2020
Discover the benefits of Hammock over Mockery for efficient testing in PHP, and learn best practices for writing effective tests, including using mocks sparingly and correctly, and utilizing Hammock's features for speed and improved code coverage.
Important concepts
- Hammock and Mockery are two different mocking libraries used for testing
- Hammock supports type-safe, performant and flexible testing
-
Mockery’s shortcomings include:
- Verbose and fluent syntax
- Heavy performance overhead
- Limited flexibility and scalability
- No support for advanced features like async functions
- Using mocks sparingly and correctly can lead to better test performance and effectiveness
Best practices
- Mock specific functions or methods instead of whole classes
- Use disposable interfaces to limit the scope of mocking
- Avoid over-engineering and focus on simplicity
- Utilize Hammock’s features to speed up testing and improve code coverage
Language-specific considerations
- Hacklang is a dynamic programming language designed for better performance and reliability
- It has features like async functions and improved type checking
- Hack can be called into PHP and vice versa, supporting a high degree of interoperability
Open-source contributions
- The community advocate behind Hammock highlights the importance of open-source contributions
- Recognizes the efforts of Lexeter, the lead developer of Hammock