Behat for beginners functional REST API testing tutorial. (see shortcuts below to key points) Adam Culp of Beachcasts programming videos walks through a php tutorial on how to install Behat, a PHP framework for Behavior Driven Development. Then I create BDD tests to test a REST API using GuzzleHttp from within Behat. This allows easy api testing through test automation, and behaviour driven development for software testing.
Please * LIKE, COMMENT, AND SUBSCRIBE * – and share with others!
Key Topics:
– Installing Behat and Guzzle using Composer
– Configure Behat for a PHP project
– Create a Behat Context
– Create Behat Features and Scenarios
– Include variables in Behat Scenarios
For a nice list of equipment I use in my studio, and to support the channel if you make any purchases (doesn’t cost you a thing), visit my kit at kit.co: https://kit.co/beachcasts/beachcasts-studio
Errata:
Let me know if you notice anything that should be errata
Associated Links:
http://behat.org/en/latest/ – Main Behat PHP framework for behavioral autotesting site
Timeline:
00:00 Video Intro
01:15 Install Behat PHP behavior testing framework using Composer
01:55 Install GuzzleHttp PHP HTTP client using Composer
03:10 How to get Behat version in command line CLI
03:33 How to initialize Behat testing structure
04:40 How to launch Behat from command line CLI
05:50 How to create a Feature
06:25 Define a Scenario and testing steps
06:45 Using Given keyword
07:03 Using When keyword
07:20 How to use variable information in a tests
08:05 Using Then keyword
09:25 Launch Behat to run tests, and/or to create missing scenario steps
09:55 Using scenario steps created by Behat
10:45 How to use PendingExceptions() in of Behat
12:30 Using GuzzleHttp Client to make call to an API endpoint
13:35 Get HTTP response code from GuzzleHttp response
14:05 Validate a resonse code or thow an Exception
16:20 Using variable in tests that were created by Feature quoted values
18:30 Create test to look for specific data item in a JSON response
18:55 Refactor to move temporary variable to a protected field within a class, for use by other methods
21:05 Use json_decode to build an array with the JSON response of the API
21:55 How to handle HAL driven multi-dimensional array for looping.
23:50 Doing comparison of UUID in HTTP response
25:20 How to create ‘Behat.yml’ configuration file to set up multiple Context files
Other Beachcasts videos you might find interesting:
Make your local DEV environment available on the internet https://youtu.be/xs2o7B_Ex9E
AWS Elastic Load Balancer (ELB) Tutorial How-To https://youtu.be/Sr2Mq9Gegew
Laravel Model Factory Tutorial using Artisan make:model https://youtu.be/hM135dPJ1dM
Authentication in Laravel Tutorial https://youtu.be/2qJkzWJNpjQ
Top 5 skills to be a better software developer https://youtu.be/kbX8iATLqxs
Install Laravel in Docker container on Ubuntu for beginners https://youtu.be/0HTruhilvcU
Getters and Setters accessors in object oriented programming https://youtu.be/cozignPaoLg
Critical programming issues preventing a PHP 7 upgrade https://youtu.be/z13glyDnm6s
Doctrine ORM one-to-many bi-directional association https://youtu.be/4nEdBDxBc1w
PHP Mess Detector static analysis to find PHP code smells https://youtu.be/8fEfHESrK5E
Doctrine ORM one-to-many self-referencing association https://youtu.be/4dHZ6cZooOk
10 reasons to become a consultant in a consulting business https://youtu.be/J7gpMYAKmDM
Zend Framework becomes Laminas project at Linux Foundation https://youtu.be/CEIO90ocEDI
10 bad things about consulting https://youtu.be/ELE0G3e7h3c
How to get lines of code in PHP https://youtu.be/HpC-Cvxj6oY
Make a List handler middleware https://youtu.be/VLqavHCFv6g
Make a Delete handler middleware https://youtu.be/3nLbQfMk99k
Make an Update handler middleware https://youtu.be/3Zcq5Jjz1Po
Use UUID with Doctrine ORM for DB keys https://youtu.be/SYuLwMwSIpg
Make a Create handler middlware https://youtu.be/FIYh-VIWUko
Automate Hypermedia creation for PHP REST API https://youtu.be/dX6S-pJVUXI
Learn about Hypermedia and how to create it https://youtu.be/aV6ro_JXL_A
Doctrine ORM Paginator for PHP REST API https://youtu.be/UpqOew4sNT0
Doctrine ORM Entity how to https://youtu.be/NnK9Geg1h_E
Configure Doctrine ORM https://youtu.be/pFvh5ZNhdOQ
Create PHP middlware with Zend Expressive https://youtu.be/26440j7D0BE
Configure PhpStorm for PHP development with Docker https://youtu.be/FQWL-JTZvf4
Create PHP development environment with docker https://youtu.be/2ESAi2vq-80
Help through referrals:
Thinking of buying a Tesla electric vehicle? Use this referral link to also get six months of free Supercharging for both of us. Thank you. https://www.tesla.com/referral/tanya21367
I use TubeBuddy to help me manage my YouTube channel. If you’re interested, click the following link to check it out. https://www.tubebuddy.com/beachcasts
#BehatPHP #BDD #beachcasts
Comments