Learn some advanced tips and tricks to use in your data providers to enable better feedback from your unit tests.
- [Instructor] The last video explored the basics…of how to use a data provider to provide…more inputs to a test method.…In this one, we'll look at some of the more advanced…ways that we can use a data provider…to expand upon our tests.…First, open up the Receipt Test class which…is located in our tests directory.…So what else can we do with a data provider?…Well, recall we are passing an array to the test method,…what is the key for the test?…In our case right now, it's just an integer.…So we can filter our test actually by that particular key.…
If you go to your terminal,…and run the command vendor/bin/phpunit --filter…is equal to pass in the name of the test…we want to filter by, testTotal,…and then pass the integer that corresponds to the key…in that data provider we want to run.…In this case we'll just pass number one,…and you'll see we only run one test.…What happens if we want to pass in a range of ID values,…we can modify our command and pass in 1-2,…and here we'll run two tests with two matching assertions.…
- Why use unit testing?
- Writing unit tests
- Extending unit tests
- Filtering PHPUnit tests
- Building dummy objects
- Working with data providers
- Writing an exception-based test
- Using TDD tactics
- Using PHPUnit advanced tactics, such as database tests
Skill Level Intermediate
PHP: Managing Persistent Sessionswith David Powers2h 41m Intermediate
1. The Basics of Test-Driven Development
2. Advanced Test-Driven Development
3. Test-Driven Development Tactics
4. PHPUnit Advanced Tactics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.