Test WebServices With Codeception
Published on June 19, 2012
Codeception testing framework got significant improvements during last week. The first and the major one is that you don’t even need PEAR and Composer to execute tests. Only one file
codecept.phar required. This might save your time and mind of your testers.
So Installation is much simplier now:
Execute it with PHP
Now you can start generating a test suite with
php codecept.phar bootstrap or execute existing tests with
php codecept.phar run.
Documentation section was created. New section Reference was added. There you can review Codeception commands and configuration values.
But the most cool stuff is new module for testing web services!
Modules for SOAP and REST were added recently. You know it’s always hard to test the API manually. So why not to automate it?
This API modules keeps simple manner in describing tests. Take a look at sample REST test.
And here goes a sample SOAP test:
Ok, the one thing you may have noticed. We are working with JSON in first case and XML in second. But there is no JSON or XML in code! Well, we could have used it, but we didn’t. Just because we can use PHP to set data in this formats. Json is built from PHP arrays and for XML is used jQuery-like styled XMLBuilder class. But you could possibly add a raw json or XMl into your tests. No problems with that!
Modules themselves are already documented and tested. Soon a complete guide on WebService API testing will be added.
The other thing worth to mention is new finalizers in test scenarios. If you need to execute code after test is finished and you don’t want to put it in helper use the
$scenario->finilize method. See it’s usage example in new Manual Cleanup section of Guides.
This is Codeception 1.0.11. Download new version to run tests or update
or via Composer