Date post: | 18-Oct-2014 |
Category: |
Technology |
View: | 1,836 times |
Download: | 4 times |
Arquillian: Effective TestsArquillian: Effective TestsFROM THE CLIENT TO THE SERVERFROM THE CLIENT TO THE SERVER
Lukas Fryc
TestingTestingTestingTestingTestingTestingTestingTestingTestingTestingTesting
#Agile
#TDD
“You can hear about testingfrom everywhere!”
Enterprise Java Web Application
“But image testing of large enterprise application.”
Testing...
“In such case, it's not easy to define how the tests should look like.”
Testing = ?
“How would you complete equation?
What word do you imagine when someone says testing?”
Testing = Pain
“My favorite is...”
Testing = Enjoyable!
“It's even possible to change equation and make the testing enjoyable?”
No one saves the World?
“There is one: he is brave and comes from far deep space...”
“And brings heavy gear for fighting with alien bugs...”
“...and he is proud to share his powerful gear with us!”
“At first, he comes withAbility to split one big
deployment into many small, testing as little as components as possible
in separation.”
“And he makes sure these deployments work
on various of earth application servers.”
“...and once he deploys the deployment into
container, he makes sure you have all the goodness
from inside available using dependency
injection.”
“...and that's all backed with strong development
tools.”
TestNGJUnit
“That all, and you can run it just from your IDE, re-using what you already
now.”
Testing Revolution
Ike brings tests to the Server
But what about the Client?
The little bit of Theory...
“Let's have ideal testing pyramid in mind, otherwise...”
Enough Theory!
Let's bring tests to the Client
“But it isn't as simple as in Java - many different environments.”
“Fortunately there is tool which allows you to write tests in unified API for all those browsers.”
“And the even supports mocked browsers with same API.”
Oh, such a great tool!
Let's invade client!
“Ouch, we need some
abstraction!”
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!”
At least, the app is covered...
“But this is what actually Selenium see.”
Black Box
Page Transitions
“Selenium is able to test transitions between pages.”
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.”
Let's change the game...
Right tool for the Job
“Let's take the an outstanding UI automation tool...”
“And add your favorite language.”
“And little bit of Alien technology.”
Arquillian Drone
“His name is Drone and he is proud member of Arquillian crew!”
Hard-Worker
“He is basically ...”
“Drone comes to bring the browser to your test.”
Let Ike invade the Client
“But something else is needed to make your tests green.”
“Something enough strong to handle all the inconsistencies.”
“Let's deploy that to the browser page and see what happens!”
Strong type-safe API
Proven to handle AJAX
Invades the Client
Cross-Cutting Concerns
Arquillian Graphene
Isn't that too low-level?
“We are still writing low-level interaction commands, right?”
Reusable Abstractions
“Let's look for something on higher level.”
Page Objects
“Introducing well-known Selenium pattern:”
“Let's imagine you have page with all the elements and you express them as fields in the class.”
“You can even use fluent API for page transitions, since each method can return next page as the result.”
“But for modern AJAX-based application, it's simply not enough.”
“Let's think a little about that:
In enterprise applications, you rather reuse UI components.”
“What about creating the model of these components from their user's point of view?”
Component Objects
Arquillian GrapheneComponent Objects
Review what we have
“Now, we can simply write tests on proper level of abstraction with minimum efforts.”
3MissingPieces
TestNGJUnit
“What is missing here?”
How to avoid manual...?
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.”
Automated Visual Verification
The Music of the Future?
Arquillian RushEye
“It is music of the future, but there is project which already focuses efforts there.”
TestNGJUnit
“2 parts are missing now: server is already covered with unit and integration tests, but what about the
same tests for client?”
Unit Testing Client
“Unit testing of client is even more important than unit testing of server, since it suffers from environment diversity.”
Yet another tool to configure?
“But once those unit tests are written, how to automate them?
Without automation, they are not tests.”
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.”
QUnit
“For writing actual tests, you can use your favorite JS client testing tool.
We are actually working on integration with QUnit.”
TestNGJUnit
“And once the client is covered too, only
integration tests for client are missing.”
Client / Server Round-Trip
“The integration testing of client is actually making sure it communicates with server as expected.”
Take client on the Tour to Server!
“We have browser and test on one side and
server on opposite side.”
“With UI automation, we are sending request from
client to the server.”
“And server generates response.”
Black Box!
“On the other hand, when we are testing server from its JVM, we are
mocking requests, which invokes verification
code.”
Don't mock me!
“Let's make the connection between client
and server live.”
“Once the requests goes to the server, the test code is serialized and
sent as part of the request.”
“Server de-serializes the testing code from request and uses it for verification
of the server state in several lifecycle phases.”
“And then is the testing object sent back to the
client, which can validate it.”
“Client can verify the response and send another request.”
Crazy idea?
JSFUnit
“But it already works!”
TestNGJUnit
“Now, we are covered!”
Client Invasion
It's all?
It can't be without some buzz....
Let's go Mobile!
“Drone can actually replace all the browsers.”
“And use Android driver for connecting to mobile
device.”
“Additionally, Android extension can start the emulator or connect to
real device, which is perfect addition for
running in continuous integration systems.”
Arquillian Android
“Drone brings your Android browser just into
your test.”
Arquillian
Experience the future now
But I must to know more...
http://bit.ly/arq-preview
http://bit.ly/arq-users
Join us...
http://github.com/arquillian
http://bit.ly/arq-devs
http://bit.ly/jboss-testing
#jbosstesting @ irc.freenode.net
#Arquillian
Enjoy the Testing!
@LFrycLukas Fryc
http://bit.ly/lfryc
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