This workshop is for those who know how to write developer tests in PHPUnit. This workshop will expand upon that knowledge and further emphasize the difference between unit testing and integration testing. We will cover better tools and techniques for integration testing with databases and external services, and we will cover advanced mocking techniques to maintain a more fast and robust test suite.
Topics include: DBUnit, PHPUnit Mocks, Mockery, vfsStream
This course requires prior experience with PHPUnit or the 'Developer Testing 101: Become a Testing Fanatic' course.
Report
Share
Report
Share
1 of 98
More Related Content
Developer testing 201: When to Mock and When to Integrate
2. Goals
• Learn advanced unit testing techniques
• Build a toolbox for integration testing
• Begin to be able to assess appropriate
testing needs and usages
3. Non-Goals
• Not an introduction to testing
• Not to necessarily learn how to write
the best (code) tests, but getting closer
16. When Do They Work?
• During prototyping
• Focused on the product requirements
• Refactoring
• Regression of key features
• Better for smaller teams
30. More Sources of Flake
• Sleep
• Date/Time
• Random Number Generators
• Multiple-Processes
31. @group
• @group cache
• for test that use memcache
• @group dbunit
• for test that use DBUnit and databases
• @group network
• for tests that talk to external services
• @group flaky
• for tests that fail without a code change
32. Unit Tests are DEFAULT
There is NO @group for unit tests.
33. Test Sizes
• New in PHPUnit 3.6
• @small run in less than one second
• @medium run in less than 10 seconds
• @large run in less than 60 seconds
• Note: All times are configurable
97. Closing Thoughts
• Minimize Integration Points
• Minimize Integration Tests
• Wrap External (Hostile) Dependencies
• Try to Avoid Test Fixture Files
• Test Your Custom Test Tools
• Consider Alert Systems, not CI