tasting your first test burger

29
Tasting Your First Test Burger Tautrimas Pajarskas

Upload: tautrimas-pajarskas

Post on 06-Aug-2015

534 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Tasting Your First Test Burger

Tasting Your First Test Burger

Tautrimas Pajarskas

Page 2: Tasting Your First Test Burger

About Me:

Tautrimas Pajarskas

PHP Team Lead,Lecturer at NFQ Academy,

Striving for efficient and scalable projects development

Page 3: Tasting Your First Test Burger

Goals Today

Observation: Automated testing is not used with legacy projects.

My goal is to encourage you to start testing.Today I will present you the HOW TO part.

Page 4: Tasting Your First Test Burger

What is Automated Testing?

Making someone do clicking for you (:

Page 5: Tasting Your First Test Burger

I am a Member of ONGR

We do Unit, Integration, Functional and Acceptance testing. > 90% test coverage.

Page 6: Tasting Your First Test Burger

First Time Testing is Like Trying a Burger

Too much stuff!

Page 7: Tasting Your First Test Burger

Continuous Integration

Example:https://travis-ci.org/ongr-io/ongr-sandbox

Page 8: Tasting Your First Test Burger

Databases

Q: I want to test deleting a user. How to login after that?A: Use fixtures.Q: ?

Page 9: Tasting Your First Test Burger

Which ones should I do?

Types of Tests

Page 10: Tasting Your First Test Burger

Tools

PHPUnit or phpspec?Behat using Selenium or CasperJS?

Difficult to choose without guidance.

Page 11: Tasting Your First Test Burger

Advice:Simply try CasperJS. Acceptance testing.

And if you cannot experiment at workDon’t do it at home!

Page 12: Tasting Your First Test Burger

Demo Time!

Page 13: Tasting Your First Test Burger

Demo Overview

1. Write basic CasperJS test2. Test dynamic Bootstrap feature3. Use Resurrectio recorder4. Use PhantomCSS for design testing

Page 14: Tasting Your First Test Burger

Our Example Legacy Project

Page 15: Tasting Your First Test Burger

First Test

Page 16: Tasting Your First Test Burger

Taking a Screenshot for debugging

Page 17: Tasting Your First Test Burger

Fixing Desktop Viewport Size

Page 18: Tasting Your First Test Burger

Test Dropdown Menu Works

Page 19: Tasting Your First Test Burger

Try out Resurrectio

https://github.com/ebrehault/resurrectio

Resurrectio is a Chrome extension allowing to record a sequence of browser actions and to produce the corresponding CasperJS script.

-- Resurrectio README.md

Page 20: Tasting Your First Test Burger

Start the Recording

Page 21: Tasting Your First Test Burger

Resulting Script After a Few Clicks

Page 22: Tasting Your First Test Burger

PhantomCSS: CSS regression testing

Let’s “accidentally” change <h1> font-size down

Page 23: Tasting Your First Test Burger

PhantomCSS: CSS regression testing

PhantomCSS is good for detecting any visual changes that are hard to sample using scripts.

Only do screenshot parts of the page. Otherwise, the change in the footer will fail every single page test in the test suite.

Page 24: Tasting Your First Test Burger

PhantomCSS: CSS regression testing

Increasing number of screenshots can get large for GIT. Use another GIT repo for them or look up solutions offered in:

https://github.com/Huddle/PhantomCSS

Page 25: Tasting Your First Test Burger

PhantomCSS: CSS regression testing

Use PhantomCSS only for design testing and only where it is needed.

Otherwise, screenshot diff collision madness will occur in your team (:

Page 26: Tasting Your First Test Burger

Summary

Page 27: Tasting Your First Test Burger

Summary for Legacy Projects

Isolate project’s testing version locally on a separate vhost and a separate DB.

Write a script that prepares project for testing. E. g. loads testing data for DB.

Start with highest level tests shown today.

Page 28: Tasting Your First Test Burger

Summary for Legacy Projects

Later, try out your Framework testing functionality for Unit testing. You will need it for much faster and fine grained tests. Remember to delete and rewrite crappy tests!

Experiment, acquire testing skills and spread the success stories!

Page 29: Tasting Your First Test Burger

Thank You!

Follow hottest web technology news atfacebook.com/nfq.lt