123
Arquillian: Effective Tests Arquillian: Effective Tests FROM THE CLIENT TO THE SERVER FROM THE CLIENT TO THE SERVER Lukas Fryc

Arquillian: Effective tests from the client to the server

  • View
    1.837

  • Download
    4

Embed Size (px)

DESCRIPTION

Tools like Selenium, an outstanding tool for UI test automation, and Arquillian, an award-winning integration testing framework, offer a base for high-quality tests which are crucial for a web app development. However writing UI tests and covering server-side logic leaves many questions open:* Does Selenium cover everything? Page transitions, simple JavaScript interaction and a portion of DOM. Is it really enough?* Mocking requests for testing server-side code is pain. Is it necessary?* Are you able to detect that your component’s visual representation changes?* Does investigating these changes involve a disproportionate amount of effort?* Isn’t manual test development too expensive?

Citation preview

Page 1: Arquillian: Effective tests from the client to the server

Arquillian: Effective TestsArquillian: Effective TestsFROM THE CLIENT TO THE SERVERFROM THE CLIENT TO THE SERVER

Lukas Fryc

Page 2: Arquillian: Effective tests from the client to the server

TestingTestingTestingTestingTestingTestingTestingTestingTestingTestingTesting

#Agile

#TDD

“You can hear about testingfrom everywhere!”

Page 3: Arquillian: Effective tests from the client to the server

Enterprise Java Web Application

“But image testing of large enterprise application.”

Page 4: Arquillian: Effective tests from the client to the server

Testing...

“In such case, it's not easy to define how the tests should look like.”

Page 5: Arquillian: Effective tests from the client to the server

Testing = ?

“How would you complete equation?

What word do you imagine when someone says testing?”

Page 6: Arquillian: Effective tests from the client to the server

Testing = Pain

“My favorite is...”

Page 7: Arquillian: Effective tests from the client to the server

Testing = Enjoyable!

“It's even possible to change equation and make the testing enjoyable?”

Page 8: Arquillian: Effective tests from the client to the server

No one saves the World?

Page 9: Arquillian: Effective tests from the client to the server

“There is one: he is brave and comes from far deep space...”

Page 10: Arquillian: Effective tests from the client to the server

“And brings heavy gear for fighting with alien bugs...”

Page 11: Arquillian: Effective tests from the client to the server

“...and he is proud to share his powerful gear with us!”

Page 12: Arquillian: Effective tests from the client to the server

“At first, he comes withAbility to split one big

deployment into many small, testing as little as components as possible

in separation.”

Page 13: Arquillian: Effective tests from the client to the server

“And he makes sure these deployments work

on various of earth application servers.”

Page 14: Arquillian: Effective tests from the client to the server

“...and once he deploys the deployment into

container, he makes sure you have all the goodness

from inside available using dependency

injection.”

Page 15: Arquillian: Effective tests from the client to the server

“...and that's all backed with strong development

tools.”

Page 16: Arquillian: Effective tests from the client to the server

TestNGJUnit

“That all, and you can run it just from your IDE, re-using what you already

now.”

Page 17: Arquillian: Effective tests from the client to the server

Testing Revolution

Page 18: Arquillian: Effective tests from the client to the server

Ike brings tests to the Server

Page 19: Arquillian: Effective tests from the client to the server

But what about the Client?

Page 20: Arquillian: Effective tests from the client to the server

The little bit of Theory...

Page 21: Arquillian: Effective tests from the client to the server
Page 22: Arquillian: Effective tests from the client to the server
Page 23: Arquillian: Effective tests from the client to the server
Page 24: Arquillian: Effective tests from the client to the server
Page 25: Arquillian: Effective tests from the client to the server

“Let's have ideal testing pyramid in mind, otherwise...”

Page 26: Arquillian: Effective tests from the client to the server

Enough Theory!

Page 27: Arquillian: Effective tests from the client to the server

Let's bring tests to the Client

Page 28: Arquillian: Effective tests from the client to the server

“But it isn't as simple as in Java - many different environments.”

Page 29: Arquillian: Effective tests from the client to the server

“Fortunately there is tool which allows you to write tests in unified API for all those browsers.”

Page 30: Arquillian: Effective tests from the client to the server

“And the even supports mocked browsers with same API.”

Page 31: Arquillian: Effective tests from the client to the server

Oh, such a great tool!

Page 32: Arquillian: Effective tests from the client to the server

Let's invade client!

Page 33: Arquillian: Effective tests from the client to the server

“Ouch, we need some

abstraction!”

Page 34: Arquillian: Effective tests from the client to the server

JavaC#

PythonRubyPHPPerl

“Even if we use favorite programmatic approach, we can end up with many tests which takes days to pass and quickly turns out into maintanance burden!”

Page 35: Arquillian: Effective tests from the client to the server

At least, the app is covered...

Page 36: Arquillian: Effective tests from the client to the server

“But this is what actually Selenium see.”

Page 37: Arquillian: Effective tests from the client to the server

Black Box

Page 38: Arquillian: Effective tests from the client to the server

Page Transitions

“Selenium is able to test transitions between pages.”

Page 39: Arquillian: Effective tests from the client to the server

A little bit of...DOM / JavaScript / CSS

“...and a portion of all the page source code – JavaScript handlers, selected CSS and DOM changes as reaction to user interaction.”

Page 40: Arquillian: Effective tests from the client to the server

Let's change the game...

Page 41: Arquillian: Effective tests from the client to the server

Right tool for the Job

Page 42: Arquillian: Effective tests from the client to the server

“Let's take the an outstanding UI automation tool...”

Page 43: Arquillian: Effective tests from the client to the server

“And add your favorite language.”

Page 44: Arquillian: Effective tests from the client to the server

“And little bit of Alien technology.”

Page 45: Arquillian: Effective tests from the client to the server

Arquillian Drone

“His name is Drone and he is proud member of Arquillian crew!”

Page 46: Arquillian: Effective tests from the client to the server

Hard-Worker

“He is basically ...”

Page 47: Arquillian: Effective tests from the client to the server

“Drone comes to bring the browser to your test.”

Page 48: Arquillian: Effective tests from the client to the server

Let Ike invade the Client

Page 49: Arquillian: Effective tests from the client to the server

“But something else is needed to make your tests green.”

Page 50: Arquillian: Effective tests from the client to the server

“Something enough strong to handle all the inconsistencies.”

Page 51: Arquillian: Effective tests from the client to the server

“Let's deploy that to the browser page and see what happens!”

Page 52: Arquillian: Effective tests from the client to the server

Strong type-safe API

Page 53: Arquillian: Effective tests from the client to the server

Proven to handle AJAX

Page 54: Arquillian: Effective tests from the client to the server

Invades the Client

Page 55: Arquillian: Effective tests from the client to the server

Cross-Cutting Concerns

Page 56: Arquillian: Effective tests from the client to the server

Arquillian Graphene

Page 57: Arquillian: Effective tests from the client to the server

Isn't that too low-level?

“We are still writing low-level interaction commands, right?”

Page 58: Arquillian: Effective tests from the client to the server

Reusable Abstractions

“Let's look for something on higher level.”

Page 59: Arquillian: Effective tests from the client to the server

Page Objects

“Introducing well-known Selenium pattern:”

Page 60: Arquillian: Effective tests from the client to the server

“Let's imagine you have page with all the elements and you express them as fields in the class.”

Page 61: Arquillian: Effective tests from the client to the server
Page 62: Arquillian: Effective tests from the client to the server

“You can even use fluent API for page transitions, since each method can return next page as the result.”

Page 63: Arquillian: Effective tests from the client to the server

“But for modern AJAX-based application, it's simply not enough.”

Page 64: Arquillian: Effective tests from the client to the server

“Let's think a little about that:

In enterprise applications, you rather reuse UI components.”

Page 65: Arquillian: Effective tests from the client to the server

“What about creating the model of these components from their user's point of view?”

Page 66: Arquillian: Effective tests from the client to the server

Component Objects

Page 67: Arquillian: Effective tests from the client to the server

Arquillian GrapheneComponent Objects

Page 68: Arquillian: Effective tests from the client to the server

Review what we have

Page 69: Arquillian: Effective tests from the client to the server

“Now, we can simply write tests on proper level of abstraction with minimum efforts.”

Page 70: Arquillian: Effective tests from the client to the server

3MissingPieces

Page 71: Arquillian: Effective tests from the client to the server

TestNGJUnit

“What is missing here?”

Page 72: Arquillian: Effective tests from the client to the server

How to avoid manual...?

Page 73: Arquillian: Effective tests from the client to the server

Screen-shot Comparison

“We can automatically snap screen-shots of the

whole pages and compare them with historical data – it's

proven that rendering on one particular browser

and platform, images will be binary same.”

Page 74: Arquillian: Effective tests from the client to the server

Automated Visual Verification

Page 75: Arquillian: Effective tests from the client to the server

The Music of the Future?

Page 76: Arquillian: Effective tests from the client to the server

Arquillian RushEye

“It is music of the future, but there is project which already focuses efforts there.”

Page 77: Arquillian: Effective tests from the client to the server

TestNGJUnit

“2 parts are missing now: server is already covered with unit and integration tests, but what about the

same tests for client?”

Page 78: Arquillian: Effective tests from the client to the server

Unit Testing Client

“Unit testing of client is even more important than unit testing of server, since it suffers from environment diversity.”

Page 79: Arquillian: Effective tests from the client to the server

Yet another tool to configure?

“But once those unit tests are written, how to automate them?

Without automation, they are not tests.”

Page 80: Arquillian: Effective tests from the client to the server

Reuse the Automation Setup

“Let's use the configuration what we have for Drone – let him instantiate a browser, which will run the unit tests.”

Page 81: Arquillian: Effective tests from the client to the server

QUnit

“For writing actual tests, you can use your favorite JS client testing tool.

We are actually working on integration with QUnit.”

Page 82: Arquillian: Effective tests from the client to the server

TestNGJUnit

“And once the client is covered too, only

integration tests for client are missing.”

Page 83: Arquillian: Effective tests from the client to the server

Client / Server Round-Trip

“The integration testing of client is actually making sure it communicates with server as expected.”

Page 84: Arquillian: Effective tests from the client to the server

Take client on the Tour to Server!

Page 85: Arquillian: Effective tests from the client to the server

“We have browser and test on one side and

server on opposite side.”

Page 86: Arquillian: Effective tests from the client to the server

“With UI automation, we are sending request from

client to the server.”

Page 87: Arquillian: Effective tests from the client to the server

“And server generates response.”

Page 88: Arquillian: Effective tests from the client to the server

Black Box!

Page 89: Arquillian: Effective tests from the client to the server

“On the other hand, when we are testing server from its JVM, we are

mocking requests, which invokes verification

code.”

Page 90: Arquillian: Effective tests from the client to the server

Don't mock me!

Page 91: Arquillian: Effective tests from the client to the server

“Let's make the connection between client

and server live.”

Page 92: Arquillian: Effective tests from the client to the server

“Once the requests goes to the server, the test code is serialized and

sent as part of the request.”

Page 93: Arquillian: Effective tests from the client to the server

“Server de-serializes the testing code from request and uses it for verification

of the server state in several lifecycle phases.”

Page 94: Arquillian: Effective tests from the client to the server

“And then is the testing object sent back to the

client, which can validate it.”

Page 95: Arquillian: Effective tests from the client to the server

“Client can verify the response and send another request.”

Page 96: Arquillian: Effective tests from the client to the server

Crazy idea?

Page 97: Arquillian: Effective tests from the client to the server

JSFUnit

“But it already works!”

Page 98: Arquillian: Effective tests from the client to the server

TestNGJUnit

“Now, we are covered!”

Page 99: Arquillian: Effective tests from the client to the server
Page 100: Arquillian: Effective tests from the client to the server

Client Invasion

Page 101: Arquillian: Effective tests from the client to the server

It's all?

Page 102: Arquillian: Effective tests from the client to the server

It can't be without some buzz....

Page 103: Arquillian: Effective tests from the client to the server

Let's go Mobile!

Page 104: Arquillian: Effective tests from the client to the server

“Drone can actually replace all the browsers.”

Page 105: Arquillian: Effective tests from the client to the server

“And use Android driver for connecting to mobile

device.”

Page 106: Arquillian: Effective tests from the client to the server

“Additionally, Android extension can start the emulator or connect to

real device, which is perfect addition for

running in continuous integration systems.”

Page 107: Arquillian: Effective tests from the client to the server

Arquillian Android

Page 108: Arquillian: Effective tests from the client to the server

“Drone brings your Android browser just into

your test.”

Page 109: Arquillian: Effective tests from the client to the server
Page 110: Arquillian: Effective tests from the client to the server

Arquillian

Page 111: Arquillian: Effective tests from the client to the server

Experience the future now

Page 112: Arquillian: Effective tests from the client to the server

But I must to know more...

Page 113: Arquillian: Effective tests from the client to the server

http://bit.ly/arq-preview

Page 114: Arquillian: Effective tests from the client to the server

http://bit.ly/arq-users

Page 115: Arquillian: Effective tests from the client to the server

Join us...

Page 116: Arquillian: Effective tests from the client to the server

http://github.com/arquillian

Page 117: Arquillian: Effective tests from the client to the server

http://bit.ly/arq-devs

Page 118: Arquillian: Effective tests from the client to the server

http://bit.ly/jboss-testing

Page 119: Arquillian: Effective tests from the client to the server

#jbosstesting @ irc.freenode.net

Page 120: Arquillian: Effective tests from the client to the server

#Arquillian

Page 121: Arquillian: Effective tests from the client to the server

Enjoy the Testing!

Page 122: Arquillian: Effective tests from the client to the server

@LFrycLukas Fryc

http://bit.ly/lfryc

Page 123: Arquillian: Effective tests from the client to the server

http://www.flickr.com/photos/nickrussill/150410613/http://www.flickr.com/photos/audreyjm529/1240909256/http://www.flickr.com/photos/jo-h/6200225665/http://www.flickr.com/photos/stevendepolo/3796415185/http://www.flickr.com/photos/ucdaviscoe/6303100423/http://www.flickr.com/photos/sportbusiness/3542445412/http://watirmelon.com/2012/01/31/introducing-the-software-testing-ice-cream-cone/

Photographs and pictures used in this presentation are authored by various authors

and released under the Creative Commons license