[CLIW] Web testing

37
Web testing A general approach Bogdan Gaza CLIW Tuesday, January 10, 12

description

Short presentation about web testing

Transcript of [CLIW] Web testing

Page 1: [CLIW] Web testing

Web testingA general approach

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 2: [CLIW] Web testing

Agenda

What is web testing?

Tools & techniques

Practical examples - demo

Conclusions

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 3: [CLIW] Web testing

What is web testing?

• Write a lot of code implies that someday things will break / stop working

• Fixing a bug is simple, finding it can be difficult

• Finding a bug while trying to maintain cross-browser compatibility can be a nightmare

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 4: [CLIW] Web testing

What is web testing?

... software testing with a focus on web applications.

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 5: [CLIW] Web testing

How can we do web testing?

Bogdan GazaCLIW

• Different approaches:

- Unit testing client side code

- Client side performance testing

- Usability testing

- Functional testing

- etc

Tuesday, January 10, 12

Page 6: [CLIW] Web testing

Unit testing for client side code

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 7: [CLIW] Web testing

Unit testing for client side code

• Why?

• Cross browser issues

• Refactoring & Bug fixing can produce unforeseen problems

• When?

• When code base is large enough

• When cross browser compatibility is a must

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 8: [CLIW] Web testing

Unit testing for client side code

• Popular frameworks:

• QUnit

• JSUnit

• Selenium

• YUITest

• and many more

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 9: [CLIW] Web testing

Unit testing for client side code

• Popular frameworks:

• QUnit

• JSUnit

• Selenium

• YUITest

• and many more

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 10: [CLIW] Web testing

Unit testing for client side code

• QUnit

• Built for jQuery

• Break code into logical chuncks for testing

• Focus on one method at a time

• http://docs.jquery.com/QUnit

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 11: [CLIW] Web testing

Unit testing for client side code

• QUnit

Bogdan GazaCLIW

test("a basic test example", function() { ok( true, "this test is fine" ); var value = "hello"; equal( value, "hello", "We expect value to be hello" );});

module("Module A");

test("first test within module", function() { ok( true, "all pass" );});

test("second test within module", function() { ok( true, "all pass" );});

Tuesday, January 10, 12

Page 12: [CLIW] Web testing

Unit testing for client side code

• QUnit

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 13: [CLIW] Web testing

Unit testing for client side code

• Automatation

• Running unit tests outside the browser?

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 14: [CLIW] Web testing

Unit testing for client side code

• Unit tests for client side code can be integrated with current build systems

• Using Node.js / Rhino we can create a browser-like environment

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 15: [CLIW] Web testing

Unit testing for client side code

• PhantomJS

• Headless WebKit with JavaScript API

• Native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

• PhantomJS can be controlled or scripted using JavaScript API

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 16: [CLIW] Web testing

Unit testing for client side code

• PhantomJS

• Headless WebKit with JavaScript API

• Native support for various web standards: DOM handling, CSS selector, JSON, Canvas, and SVG.

• PhantomJS can be controlled or scripted using JavaScript API

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 17: [CLIW] Web testing

Client side performance testing

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 18: [CLIW] Web testing

Bogdan GazaCLIW

Client side performance testing

In order to measure client side performance testing, metrics about the environment need to be gathered.

Ex:How much times does it take to load the page?

Tuesday, January 10, 12

Page 19: [CLIW] Web testing

Bogdan GazaCLIW

Client side performance testing

• Measuring:

• Insert JS code and measure performance

• Browser web developer tools - waterfall diagram

Tuesday, January 10, 12

Page 20: [CLIW] Web testing

Bogdan GazaCLIW

Client side performance testing

Tuesday, January 10, 12

Page 21: [CLIW] Web testing

Usability testing

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 22: [CLIW] Web testing

Bogdan GazaCLIW

Usability testing

• Usability testing is a technique used in user-centered interaction design to evaluate a product by testing it on users. (Wikipedia)

Tuesday, January 10, 12

Page 23: [CLIW] Web testing

Bogdan GazaCLIW

Usability testing

• How?

• Hallway testing: random set of people are brought to test the product/service.

• Expert review: use experts (possibly from companies that specialize in usability testing)

• Usually complicated and error prone

Tuesday, January 10, 12

Page 24: [CLIW] Web testing

Functional testing

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 25: [CLIW] Web testing

Bogdan GazaCLIW

Functional testing

• Functional testing is a type of black box testing that bases its test cases on the specifications of the software component under test.

• Black-box: http://en.wikipedia.org/wiki/Black_box_testing

Tuesday, January 10, 12

Page 26: [CLIW] Web testing

Bogdan GazaCLIW

Functional testing

• How?

• Specifying scenarios:

Feature: Addition In order to avoid silly mistakes As a math noobie I want to be told the sum of two numbers

Tuesday, January 10, 12

Page 27: [CLIW] Web testing

Bogdan GazaCLIW

Functional testing

• How?

• Specifying scenarios:

Scenario Outline: Add two numbers Given I have entered <input_1> into the calculator And I have entered <input_2> into the calculator When I press <button> Then the result should be <output> on the screen

Tuesday, January 10, 12

Page 28: [CLIW] Web testing

Bogdan GazaCLIW

Functional testing

• How?

• Selenium

Tuesday, January 10, 12

Page 29: [CLIW] Web testing

Bogdan GazaCLIW

Functional testing

• Selenium

• Test automation tool for web applications

• Can be used for most of the browsers/platform combinations

• Supports many languages

Tuesday, January 10, 12

Page 30: [CLIW] Web testing

Bogdan GazaCLIW

Functional testing

• Selenium IDE

• Firefox plugin

• IDE for selenium tests

• Provides record and playback functionalities

• Exports tests in different formats (HTML, Ruby, Python etc)

Tuesday, January 10, 12

Page 31: [CLIW] Web testing

Practical examples - demo

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 32: [CLIW] Web testing

Conclusions

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 33: [CLIW] Web testing

Client-side web testing improves the quality of your software

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 34: [CLIW] Web testing

Client-side web testing can be cumbersome

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 35: [CLIW] Web testing

But saves bug tracking/fixing time, and is a must in business critical software

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 36: [CLIW] Web testing

Questions!

Bogdan GazaCLIW

Tuesday, January 10, 12

Page 37: [CLIW] Web testing

Thanks!

Bogdan GazaCLIW

Tuesday, January 10, 12