Upload
elias-nogueira
View
533
Download
5
Embed Size (px)
Citation preview
JAVA TEST AUTOMATION FORREST | WEB | MOBILE
E L I A S N O G U E I R A@ e l i a s n o g u e i r a
E D S O N Y A N A G A@ y a n a g a
Elias Nogueira@eliasnogueira
Senior QA Engineer, Agile Coach & Trainer at Sicredi
Postgraduate Professor at Unisinos.br
Active community engagement- The Developers Conference- Google Developer Group- Agile Coach Meetup
Intermediate validation between back and front end
Test in REST service
To guarantee stability during continuous test cycles
Mock in REST service
Functional and Acceptance tests on Mobile UI
Test in Mobile UI
Functional and Acceptance tests on Web UI
Test in Web UI
TOOL BOXThe correct toolbox is a key in a automation process
REST APIOur API “documentation” (you may use swagger)
ExampleURLVerbAction
/api/v1/person/api/v1/personGETList persons
/api/v1/person/27/api/v1/person/:idGETGet person by id
/api/v1/person/api/v1/personPOSTCreate a person
/api/v1/person/33/api/v1/person/:idPUTUpdate a person by id
/api/v1/person/52/api/v1/person/:idDELETERemove a person by id
REST SERVICE AUTOMATIONOne of the most important layer
Have same importance as UI has
Always assert business transactions
On new services, try do validate manually first
CURL (CLI)
PostMan (Standalone application | Google Chrome extension)
MOCK FOR REST TESTSThe easiest way to create mocks for test
Microframework with Java 8 power
Great choice for micro services
Easy REST implementation to create you own mock with real response
http://sparkjava.com
MOCK FOR REST TESTSBecause you will not test in production (all the time), right?
Mock example with fixed dataUsing fixed data is a good solution to test with a
real data (req, res) without code changes
MOCK FOR REST TESTS
Mock example with dynamic dataCreate a list of pre-defined data may be a good way to
manage the testing data
Because you will not test in production (all the time), right?
REST ASSURED
Easy DSL for REST service automation
Uses the give-when-then (BDD) syntax
https://github.com/jayway/rest-assured
WHAT I NEED? What is needed to create a REST test automation with RestAssured
Import some static classes
Set the base URI, base path and port (if needed)
import static io.restassured.RestAssured.*;import static org.hamcrest.Matchers.*;
baseURI = "http://localhost";basePath = "/api";port = 4567;
REST TEST AUTOMATION You need do set the URL, path and port
Before and After (setup | tearDown) for each testsA good solution to start and stop your API mock
server using Spark
RestAssured has a fluent API to automate REST tests
RestAssured test exampleSending a GET with id 1 (given) and the assert
the response/results (then)
REST TEST AUTOMATION
SELENIUM WEBDRIVER
Browser automation API for real browsers (including IE)
Can be controller by many programming languages
http://seleniumhq.org
W3C
Simulate an real user on browser
WHAT I NEED?What you need to create your first web test with Selenium
Web browser and a driver*
A browser to use the inspect tool (native function in various browsers)
[ProTip] Use any software to change internet speed
* you will need a proper driver (executable file) to each browser
INSPECT AN WEB ELEMENT ON A BROWSERA way to get the find an element for future utilization
Inspectbutton
PROCESS TO CREATE WEB TEST SCRIPT Easy process to create all yours web test scripts
Selenium test script creation
process
Browser initialization and navigation control
(back, forward, refresh)
NavigationA way to find a web elementid, name, cssSelector, xpath
Interrogation
Wait for dynamic elements or some asynchronous request based
on web elements
SynchronizationA way to interact with the web elementsclick, clear, sendKeys, getText
Manipulation
12
34
WEB TEST AUTOMATIONSelenium has an easy DLS
Selenium Automated testComplete example with navigation, interrogation, manipulation and synchronization
1
2
3
4
Use Page Objects to create modular test scripts
Apply design patterns in your test codebase
Execute web test in different internet speeds
Use XPATH only when needed
PRO TIPS FOR WEB TEST AUTOMATIONFor a more professional test script
PRO-TIPS FOR YOUR WEB TEST SUITEIs really important divide your tests into onto suites grouped by test levels
HEADLESS TEST ACCEPTANCE TEST FUNCTIONAL TEST
AUTOMATION TEST SUITE
1 2 3 4
GIVE FAST FEEDBACK FOR CONTINUOUS TEST CYCLES
TEST THE SYSTEM IN A USER PERSPECTIVE
TEST WITH A BUSINESS RULES PERSPECTIVE
1
2
3
APPIUM
API for automation on mobile devices
Android and iOS supported
http://appium.io
Execution on emulators, devices our cloud
Test on native or hybrid apps
WHAT I NEED? Pre-reqs to create an automated test for mobile with Appium
Android SDK
Appium (via Appium.app or Nodejs)
Configure your path with (tools | platform-tools | tools/bin)SDK Platform + System Image (to the emulator)
Emulator or Real Device
INSPECT COMPONENTS You can inspect na component using uiautomatorviewer
Inspect button
Inspected component
Component attributes
PROCESS TO CREATE MOBILE TEST SCRIPT Easy process to create all your mobile test scripts
Appium test script creation
process
Capabilities like Platform, Version, Target app and others
DesiredCapabilitiesStart the session between Appiumand Device (Appium.app or Nodejs)
Session
Wait for async requests basing on components wait
SynchronizationThe same way we do with SeleniumFind and interact with components
Interrogation and Manipulation
12
34
MOBILE TEST AUTOMATIONDespite of DesiredCapabilities and Session, is the same Selenium script
Example with a pre-installed appComplete example targeting an Android platform
PRO TIPS FOR MOBILE TEST AUTOMATION For a more professional test script
1
2
3
4
Execute tests with fresh and pre installed app
Create a test suite with user focus
Test on other networks(Wi-Fi, 3G…)
Test non-function req.