![Page 1: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/1.jpg)
Implementasi Automatic Acceptance Testing di NTU
![Page 2: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/2.jpg)
HELLO!Fachrul Choliluddin You can find me at @FachrulCH
![Page 3: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/3.jpg)
Why Testing?Why should I test my code ?
![Page 4: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/4.jpg)
Reduce False assumptions
If you rely on assumptions it will surely fail…
![Page 5: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/5.jpg)
Validate that there is no regression
Make sure the code runs as expected
![Page 6: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/6.jpg)
Automate repetitive tasks
Good developers are lazy developers!!!
![Page 7: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/7.jpg)
BUT….∎ Often developers finds it hard to write ∎ Too long too run ∎ Doesn’t correspond to business logic/behaviour/user
scenario
![Page 8: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/8.jpg)
![Page 9: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/9.jpg)
Testframework
![Page 10: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/10.jpg)
∎Manual Test∎Acceptance Test∎Functional test∎Unit test
ManualA
ceptance
Functional
Unit
![Page 11: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/11.jpg)
∎ When tested individually, units of code are not guaranteed to work together
Unit Tests
![Page 12: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/12.jpg)
Functional Tests∎ Does not use a browser engine
∎ Can be plugged with the framework to access internal functions and properties (Models, validation)
∎ Use $_REQUEST, $_POST and $_GET Faster ∎ No DOM interaction (JS/Ajax/Events)
![Page 13: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/13.jpg)
Acceptance Tests∎ Enable to do request and interact with the DOM
∎ Use a browser to perform the queries ∎ Can click and fill forms ∎ Can be plugged with Selenium/PhantomJS to interact with
JavaScript and screenshots∎ Slowest tests to run
![Page 14: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/14.jpg)
MANUAL TESTING1. Open the browser 2. Go to the website 3. Login with a test user 4. Fill form to test 5. Check the new content 6. Fill form with wrong data to test the errors 7. Logout 8. Test with invalid login
![Page 15: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/15.jpg)
MANUAL TESTING1. Open the browser 2. Go to the website 3. Login with a test user 4. Fill form to test 5. Check the new content 6. Fill form with wrong data to test the errors 7. Logout
![Page 16: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/16.jpg)
MANUAL TESTING1. Open the browser 2. Go to the website 3. Login with a test user 4. Fill form to test 5. Logout
![Page 17: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/17.jpg)
MANUAL TESTING1. Open the browser 2. Go to the website 3. Login with a test user 4. Logout
![Page 18: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/18.jpg)
MANUAL TESTING1. ...No time, I know it works
![Page 19: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/19.jpg)
PROS OF AUTOMATED TESTING∎You know it works
∎You can run it again and again and again
∎No manual work to test
![Page 20: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/20.jpg)
CONS OF AUTOMATED TESTING ∎You need to write test for the code
∎Change of code can be change of test
∎Why do I need to test if I already know it works
![Page 21: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/21.jpg)
CodeceptionOne tool, multiple testing types
![Page 22: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/22.jpg)
GENERAL INTRODUCTION PROBLEM SOLVED
∎Bridge between different testing types
∎No other languages required (for php developers)
∎Extensible∎Covers all the major PHP framework
![Page 23: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/23.jpg)
∎BDD-style scenario-driver tests ∎WebServices tests (SOAP/REST/XML-RPC)
∎Generates reports(HTML/XML/JSON)
∎Laravel/Zend/Phalcon/Yii2/Symfony/Composer modules - > No excuse!
∎Integration with continuous deployment (Jenkins/Bamboo)
∎Can be used along with Selenium2 and PhantomJS for advanced tests
![Page 24: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/24.jpg)
YOU ALREADY KNOW IT! Test suites are written in PHP
You can test websites created in any language (as you are only testing the result)
![Page 25: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/25.jpg)
Install on all platformsMac OSX: brew update && brew install homebrew/php/codeception
Linuxwget http://codeception.com/codecept.phar . php codecept.phar bootstrap
Windowsphp composer.phar global require “codeception/codeception:*”
![Page 26: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/26.jpg)
Getting ready
![Page 27: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/27.jpg)
$ codecept generate:cept acceptance FirstPage$ vim tests/acceptance/FirstPageCept.php$ codecept run
<?php $I = new AcceptanceTester($scenario); $I->wantTo('See what the fuss is about'); $I->amOnPage('/'); $I->see('Hello there', 'h1'); $I->see('Click here', 'a'); $I->click('Click here'); $I->amOnPage('/login'); $I->see('Log in here'); $I->fillField('name',‘BangOcid'); $I->fillField('password','1234'); $I->click('Submit'); $I->see('Welcome');
![Page 28: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/28.jpg)
Live Coding
![Page 29: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/29.jpg)
THANKS!Any questions?
![Page 30: Codeception @ New Business Dept Adira Finance](https://reader035.vdocument.in/reader035/viewer/2022070515/587a92061a28ab58288b72f9/html5/thumbnails/30.jpg)
SlidesCarnival icons are editable shapes.
This means that you can:● Resize them without losing
quality.● Change line color, width and
style.
Isn’t that nice? :)
Examples: