30
Implementasi Automatic Acceptance Testing di NTU

Codeception @ New Business Dept Adira Finance

Embed Size (px)

Citation preview

Page 1: Codeception @ New Business Dept Adira Finance

Implementasi Automatic Acceptance Testing di NTU

Page 2: Codeception @ New Business Dept Adira Finance

HELLO!Fachrul Choliluddin You can find me at @FachrulCH

Page 3: Codeception @ New Business Dept Adira Finance

Why Testing?Why should I test my code ?

Page 4: Codeception @ New Business Dept Adira Finance

Reduce False assumptions

If you rely on assumptions it will surely fail…

Page 5: Codeception @ New Business Dept Adira Finance

Validate that there is no regression

Make sure the code runs as expected

Page 6: Codeception @ New Business Dept Adira Finance

Automate repetitive tasks

Good developers are lazy developers!!!

Page 7: Codeception @ New Business Dept Adira Finance

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
Page 9: Codeception @ New Business Dept Adira Finance

Testframework

Page 10: Codeception @ New Business Dept Adira Finance

∎Manual Test∎Acceptance Test∎Functional test∎Unit test

ManualA

ceptance

Functional

Unit

Page 11: Codeception @ New Business Dept Adira Finance

∎ When tested individually, units of code are not guaranteed to work together

Unit Tests

Page 12: Codeception @ New Business Dept Adira Finance

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

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

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

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

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

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

MANUAL TESTING1. ...No time, I know it works

Page 19: Codeception @ New Business Dept Adira Finance

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

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

CodeceptionOne tool, multiple testing types

Page 22: Codeception @ New Business Dept Adira Finance

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

∎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

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

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

Getting ready

Page 27: Codeception @ New Business Dept Adira Finance

$ 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

Live Coding

Page 29: Codeception @ New Business Dept Adira Finance

THANKS!Any questions?

Page 30: Codeception @ New Business Dept Adira Finance

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: