Feature

Transcription

Feature
Stockholm Android
BEHAVIOR-DRIVEN
DEVELOPMENT
FOR ANDROID
Miguel Á. Domínguez Coloma
Miguel Á. Domínguez Coloma (eridem.net)
eridem.net
 Miguel Ángel Domínguez Coloma
 Doing always different things






Developer
Scrum Master
Blogger
Mentor
Evangelist
Entrepreneur
 Blog: eridem.net
Miguel Á. Domínguez Coloma (eridem.net)
Miguel Á. Domínguez Coloma (eridem.net)
WHAT IS ALL THIS ABOUT
Just real experience
and
experiments
Miguel Á. Domínguez Coloma (eridem.net)
COMMUNICATION
want
stakeholders
proof
QA
how
team
Miguel Á. Domínguez Coloma (eridem.net)
COMMUNICATION
I want A
great,you will have B
stakeholders
want
proof
QA
how
team
Miguel Á. Domínguez Coloma (eridem.net)
COMMUNICATION
want
stakeholders
proof
QA
how
team
Miguel Á. Domínguez Coloma (eridem.net)
COMMUNICATION
want
stakeholders
?
proof
QA
how
team
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE LEVEL
Feature: Game categories
As customer of the mobile app
I want to see games by categories
So I can find faster the games I like.
Feature: Promotions
As a customer of the mobile app
I want to receive promotions
So I can get services cheaper or limited.
want
Feature: Pin code
As a customer of the mobile app
I want to have an alternative way to my password
So I can log in the application in a convenient way.
Miguel Á. Domínguez Coloma (eridem.net)
SCENARIO LEVEL
Feature: Game categories
As customer of the mobile app
I want to see games by categories
So I can find faster the games I like.
Scenario: access via toolbar
Given I am in the Casino Lobby
When I go to the toolbar section
Then I should see all game categories
proof
want
how
Miguel Á. Domínguez Coloma (eridem.net)
LET’S PRACTICE!
TOOLS
 UIAutomatorViewer
 Extract info from the Android app layouts
 WebDriver + Appium
 Connect to the device and send commands
 Chai
 Assertion library
 Cucumber
 BDD library with GIVEN/WHEN/THEN syntax
 Gherkin
 Language for feature definition
Miguel Á. Domínguez Coloma (eridem.net)
> UIAUTOMATORVIEWER
ANDROID_SDK/tools/uiautomatorviewer
Miguel Á. Domínguez Coloma (eridem.net)
> UIAUTOMATORVIEWER
ANDROID_SDK/tools/uiautomatorviewer
Miguel Á. Domínguez Coloma (eridem.net)
> WEBDRIVER + APPIUM (JS)
Actions
click()
tap()
setText(string)
back()
sleep(integer)
saveScreenshot(string)
npm install wd appium --save
Miguel Á. Domínguez Coloma (eridem.net)
> WEBDRIVER + APPIUM (JS)
elementByXPath(value, cb)
elementByName(value, cb)
elementById(value, cb)
npm install wd appium --save
Miguel Á. Domínguez Coloma (eridem.net)
> CHAI (JS)
Some assertions
foo.should.eventually.have.length(3);
foo.should.eventually.exists;
foo.should.become('bar');
npm install chai chai-as-promised --save
Miguel Á. Domínguez Coloma (eridem.net)
> WEBDRIVER + CHAI (JS)
wd
.elementByName(‘my_button’)
.should.eventually.exists
.click()
.elementByName(‘my_edittext’)
.setText(‘Hello world!’);
Miguel Á. Domínguez Coloma (eridem.net)
> CUCUMBER (GHERKIN)
Feature: My nice feature
As an user ____________
I want ____________
So ____________
Scenario: How to prove this feature
Given I am in ____________
When I ____________
And I ____________
Then I should ____________
Miguel Á. Domínguez Coloma (eridem.net)
> CUCUMBER (JS)
this.Given(‘I am in ____________’, function (callback) {
callback.pending();
});
this.When(‘I ____________’, function (callback) {
callback.pending();
});
this.Then(‘I should____________’, function (callback) {
callback.pending();
});
npm install cucumber --save
Miguel Á. Domínguez Coloma (eridem.net)
> PATATA.IO (JS)
appium + chai + cucumber + webdriver
npm install patata --save
+ global options file
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
Feature: Login
As an user of the Android app
I want to be able to log in
So I can use all customer specific features
Scenario: Login via Customer area
Given I am in the Login area
When I write “XXXXX” on the “Username” field
And I write “YYYYY” on the “Password” field
And I click on the “Login” button
Then I should see the “Pin” dialog
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
Feature: Login
As an user of the Android app
I want to be able to log in
So I can use all customer specific features
Scenario: Login via Customer area
Given I am in the Login area
When I write “XXXXX” on the “Username” field
And I write “YYYYY” on the “Password” field
And I click on the “Login” button
Then I should see the “Pin” dialog
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
Feature: Login
As an user of the Android app
I want to be able to log in
So I can use all customer specific features
Scenario: Login via Customer area
Given I am in the Login area
When I write “XXXXX” on the “Username” field
And I write “YYYYY” on the “Password” field
And I click on the “Login” button
Then I should see the “Pin” dialog
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
Feature: Login
As an user of the Android app
I want to be able to log in
So I can use all customer specific features
Scenario: Login via Customer area
Given I am in the Login area
When I write “XXXXX” on the “Username” field
And I write “YYYYY” on the “Password” field
And I click on the “Login” button
Then I should see the “Pin” dialog
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
Feature: Login
As an user of the Android app
I want to be able to log in
So I can use all customer specific features
Scenario: Login via Customer area
Given I am in the Login area
When I write “XXXXX” on the “Username” field
And I write “YYYYY” on the “Password” field
And I click on the “Login” button
Then I should see the “Pin” dialog
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
Feature: Login
As an user of the Android app
I want to be able to log in
So I can use all customer specific features
Scenario: Login via Customer area
Given I am in the Login area
When I write “XXXXX” on the “Username” field
And I write “YYYYY” on the “Password” field
And I click on the “Login” button
Then I should see the “Pin” dialog
Miguel Á. Domínguez Coloma (eridem.net)
GHERKIN
FEATURE: LOGIN
argument
argument
argument
Miguel Á. Domínguez Coloma (eridem.net)
CUCUMBER
FEATURE: LOGIN
parameters
argument argument
Miguel Á. Domínguez Coloma (eridem.net)
UIAUTOMATORVIEWER
FEATURE: LOGIN
references
layout queries
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: LOGIN
import components
action
reference
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: LOGIN
this could become
USERNAME_FIELD
PASSWORD_FIELD
action
reference
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: LOGIN
this could become
LOGIN_FIELD
action
reference
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: LOGIN
this could become
PIN_DIALOG
reference
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: LOGIN
http://stephenburger.deviantart.com
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: GAME
CATEGORIES
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: GAME CATEGORIES
Feature: Game Categories
As an user of the Android app
I want to have a Game Categories area
So the user can see the available categories for all games
Scenario: Accessing to Game Categories by toolbar
Given I am in the Casino lobby
When I open the left toolbar
Then I should see the following items on the menu:
| Lobby |
| Most Popular |
| Jackpot Games |
| Video Slots |
| Table Games |
| Video Pokers |
|A-Z|
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: GAME CATEGORIES
Feature: Game Categories
As an user of the Android app
I want to have a Game Categories area
So the user can see the available categories for all games
Scenario: Accessing to Game Categories by toolbar
Given I am in the Casino lobby
When I open the left toolbar
Then I should see the following items on the menu:
| Lobby |
| Most Popular |
| Jackpot Games |
| Video Slots |
| Table Games |
| Video Pokers |
|A-Z|
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: GAME CATEGORIES
Feature: Game Categories
As an user of the Android app
I want to have a Game Categories area
So the user can see the available categories for all games
Scenario: Accessing to Game Categories by toolbar
Given I am in the Casino lobby
When I open the left toolbar
Then I should see the following items on the menu:
| Lobby |
| Most Popular |
| Jackpot Games |
| Video Slots |
| Table Games |
| Video Pokers |
|A-Z|
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: GAME CATEGORIES
Feature: Game Categories
As an user of the Android app
I want to have a Game Categories area
So the user can see the available categories for all games
Scenario: Accessing to Game Categories by toolbar
Given I am in the Casino lobby
When I open the left toolbar
Then I should see the following items on the menu:
| Lobby |
| Most Popular |
| Jackpot Games |
| Video Slots |
| Table Games |
| Video Pokers |
|A-Z|
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: GAME CATEGORIES
Feature: Game Categories
As an user of the Android app
I want to have a Game Categories area
So the user can see the available categories for all games
Scenario: Accessing to Game Categories by toolbar
Given I am in the Casino lobby
When I open the left toolbar
Then I should see the following items on the menu:
| Lobby |
| Most Popular |
| Jackpot Games |
| Video Slots |
| Table Games |
| Video Pokers |
|A-Z|
Miguel Á. Domínguez Coloma (eridem.net)
GHERKIN
FEATURE: GAME CATEGORIES
Gherkin Tables
Miguel Á. Domínguez Coloma (eridem.net)
UIAUTOMATORVIEWER
FEATURE: GAME CATEGORIES
Miguel Á. Domínguez Coloma (eridem.net)
UIAUTOMATORVIEWER
FEATURE: GAME CATEGORIES
component with arguments
Miguel Á. Domínguez Coloma (eridem.net)
UIAUTOMATORVIEWER
FEATURE: GAME CATEGORIES
Be careful (en, sv, es, …)
Miguel Á. Domínguez Coloma (eridem.net)
CUCUMBER
FEATURE: GAME CATEGORIES
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: GAME CATEGORIES
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: GAME CATEGORIES
this could become
CASINO_LEFT_MENU_BUTTON
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: GAME CATEGORIES
table parameter included
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: GAME CATEGORIES
this could become
LEFT_MENU_ITEM
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO & WD
FEATURE: GAME CATEGORIES
iterate and extract
values on the table
call component with
title as argument*
Miguel Á. Domínguez Coloma (eridem.net)
FEATURE: GAME CATEGORIES
http://www.imdb.com/title/tt0017136/ (Metropolis)
Miguel Á. Domínguez Coloma (eridem.net)
REUSE
Miguel Á. Domínguez Coloma (eridem.net)
REUSE
keep some statements consistent
“I write XXX in the YYY field”
“I click in the ZZZ button”
Miguel Á. Domínguez Coloma (eridem.net)
> PATATA.IO
REUSE
import them
Miguel Á. Domínguez Coloma (eridem.net)
> PATATA.IO
REUSE
import them
Miguel Á. Domínguez Coloma (eridem.net)
REMEMBER…
Miguel Á. Domínguez Coloma (eridem.net)
YOU CAN ALWAYS MAKE YOUR
TEST PASS SUCCESSFULLY…
http://mobile.snkplaymoreusa.com/metalslug1/ (Metal Slug)
Miguel Á. Domínguez Coloma (eridem.net)
CONCLUSIONS
Miguel Á. Domínguez Coloma (eridem.net)
CONCLUSIONS
 Common way to describe features
 Stakeholders / Business side
 Team: QA, developers, UX, …
 Testing if the app is doing the right thing
 Tests are based on behaviors, not code coverage
 Work hand by hand with business side
 Mock behaviors before implementation
 Could help UX to have an idea of the desired behavior
 Developers: run tests on their local machines easily and faster
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO
OPEN SOURCE
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO
OPEN SOURCE
 From QA to QA
 Based on existing tools
 Open Source
 GOAL: you should be able to create a test in the first 5 min
 GOAL: you should be able to “forget” about setting up
emulators and download tools
 GOAL: include missing integrations with modern apps:
 Slack, TeamCity, Atlassian products, …
 GOAL: we should just need to do: npm install patata --save
Miguel Á. Domínguez Coloma (eridem.net)
PATATA.IO
OPEN SOURCE
Stockholm Android
SUBSCRIBE TO GET THE BETA WHEN READY
HTTP://PATATA.IO
Miguel Á. Domínguez Coloma (eridem.net)