Unit vs. Integration Tests
Lab: Unit & Integration Testing Basics
Video Runtime: 17:44
Notes | Transcript | Playlist
Notes
A unit test tests your code without your code’s dependencies, whereas an integration test tests your code integrated with its dependencies.
Dependencies include:
- WordPress – as it’s outside of your code.
- An external API – such as Stripe, PayPal, a help desk, weather, population, demographics, etc.
- An external package you embedded into your plugin, theme, or application, such as Guzzle, CMB2, Fulcrum’s Extender module, or Fulcrum’s Config module.
- A reusable module that you or your company built and tested separately.
In a unit test, you are testing the expected behavior for the given conditions of your code. You fake out or simulate the dependencies. We can do this using:
- Brain Monkey
- Mockery
- and others.
Then after you complete your unit tests and you are confident in your code, you build your integration tests. Here you are testing your code’s interactions with its different dependencies.
Transcript
Hands off the keyboard. Web development starts by thinking first, then planning it out, and then coding it.
Episodes
Total Lab Runtime: 04:26:49
- 1 Lab Introductionfree 13:13
- 2 How Testing Benefits Youfree 27:00
- 3 What is Testing?free 10:24
- 4 Unit vs. Integration Testsfree 17:44
- 5 Setup the Testing Environmentpro 12:21
- 6 PHPUnit & a Virtual Containerpro 08:37
- 7 Create the Composer.json Filepro 14:36
- 8 Configure PHPUnit for Both Test Suitespro 10:56
- 9 Setup Test Shortcuts in Composerpro 09:58
- 10 Setup Local's Web Serverfree 10:05
- 11 Unit Tests - Bootstrappro 14:34
- 12 Test Basicspro 12:24
- 13 Test Assertionspro 18:42
- 14 Unit Tests - Write Real Testspro 23:32
- 15 Integration Bootstrap - Overviewfree 09:01
- 16 Integration Bootstrap - Find the WordPress Test Suite's Directorypro 12:10
- 17 Integration Bootstrap - Defining Constantspro 04:06
- 18 Integration Bootstrap - Register Theme & Loadpro 07:41
- 19 Meet WP_UnitTestCasepro 12:05
- 20 Integration Tests - Write Real Testspro 15:18
- 21 Wrap it Upfree 02:22