codeception @ new business dept adira finance

Post on 15-Jan-2017

51 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Implementasi Automatic Acceptance Testing di NTU

HELLO!Fachrul Choliluddin You can find me at @FachrulCH

Why Testing?Why should I test my code ?

Reduce False assumptions

If you rely on assumptions it will surely fail…

Validate that there is no regression

Make sure the code runs as expected

Automate repetitive tasks

Good developers are lazy developers!!!

BUT….∎ Often developers finds it hard to write ∎ Too long too run ∎ Doesn’t correspond to business logic/behaviour/user

scenario

Testframework

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

ManualA

ceptance

Functional

Unit

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

Unit Tests

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)

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

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

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

MANUAL TESTING1. Open the browser 2. Go to the website 3. Login with a test user 4. Fill form to test 5. Logout

MANUAL TESTING1. Open the browser 2. Go to the website 3. Login with a test user 4. Logout

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

PROS OF AUTOMATED TESTING∎You know it works

∎You can run it again and again and again

∎No manual work to test

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

CodeceptionOne tool, multiple testing types

GENERAL INTRODUCTION PROBLEM SOLVED

∎Bridge between different testing types

∎No other languages required (for php developers)

∎Extensible∎Covers all the major PHP framework

∎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

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)

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:*”

Getting ready

$ 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');

Live Coding

THANKS!Any questions?

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:

top related