Tri-Layer Testing Framework - 2015.10compalg.inf.elte.hu/~attila/materials/TestAutomation.pdf · -...

13
12/2/2015 1 1 CONFIDENTIAL Péter Földházi Jr. [email protected] Tri-Layer Testing Framework 2 CONFIDENTIAL 1 2 3 4 Table of Contents Table of Contents Test Automation Basics Legacy Layering Techniques Tri-Layer Framework App Logic & Structure

Transcript of Tri-Layer Testing Framework - 2015.10compalg.inf.elte.hu/~attila/materials/TestAutomation.pdf · -...

12/2/2015

1

1CONFIDENTIAL

Péter Földházi Jr.

[email protected]

Tri-Layer Testing

Framework

2CONFIDENTIAL

1 2 3 4

Table of ContentsTable of Contents

Test Automation Basics

Legacy Layering Techniques

Tri-LayerFramework

App Logic & Structure

12/2/2015

2

3CONFIDENTIAL

BASICSAUTOMATIONTEST

1. Test Automation Basics

4CONFIDENTIAL

Test Automation BasicsTest Automation Basics

Processing Acceptance Criteria For Automation

Manual Testers Automation Testers

REQUIREMENTS RECEIVED

CREATE TEST CASES

SELECT CASES TO AUTOMATE

SORT OUT BY PRIORITY

MERGE COHERENT

CASES

ANALYSIS DESIGN IMPLEMENTATION

Business

12/2/2015

3

5CONFIDENTIAL

Test Automation BasicsTest Automation Basics

What shall not be automated?

Technical difficulties Resource shortage Better manually

- Limitation of

access

- Imaging

- 3rd party tool

- Lack of mocks

- Not enough

engineers

- Maintenance cost

is too high

- Look & Feel

- Layout

- Colouring &

schemes

SELECT CASES TO AUTOMATE

6CONFIDENTIAL

Test Automation BasicsTest Automation Basics

Merging Test Cases

MERGE COHERENT

CASES

Go to Login

screen

Fill in

credentials

Log in and go to

Profile screen

Do a full login

12/2/2015

4

7CONFIDENTIAL

TECHNIQUESLAYERINGLEGACY

2. Legacy Layering Techniques

8CONFIDENTIAL

Legacy Layering TechniquesLegacy Layering Techniques

The Big Mess• No separate layers

• No design at all

• Focus is on dirty and quick solution

• POCs (Proof of Concepts)

• No automation effort

12/2/2015

5

9CONFIDENTIAL

Legacy Layering TechniquesLegacy Layering Techniques

The Two Layer Framework• Commonly used

• Test Layer

• „Everything else” Layer

• Circumstantial reusability

10CONFIDENTIAL

Test layer

Test #1 Test #NTest #2

Legacy Layering TechniquesLegacy Layering Techniques

Framework Layers

Test Libraries layer

Page Models Hardware ControllersBDD Classes

12/2/2015

6

11CONFIDENTIAL

FRAMEWORKLAYERTRI

3. Tri-Layer Framework

12CONFIDENTIAL

Tri-Layer FrameworkTri-Layer Framework

A Testing Framework’s Purpose• Automated testing

• Generated reports

• Detailed logs

• Extend the knowledge of the base tool

• Decrease maintenance cost

12/2/2015

7

13CONFIDENTIAL

Tri-Layer FrameworkTri-Layer Framework

Facade Pattern• Simplified interface to a larger body of code

• Software library easier to use

• Library more readable

• Reduce dependencies

• Wrap a poorly designed collection of APIs

Test layer

Test Successful Login Test Edit ProfileTest Failed Login

Inter layer

Main Screen Profile ScreenLogin Screen

Login Flow

Facade

14CONFIDENTIAL

Test layer

Test #1 Test #NTest #2

Tri-Layer FrameworkTri-Layer Framework

Framework Layers

Inter layer

Flow Models Structure Models

Core layer

Base Test Additional LibrariesProject Common

Library

12/2/2015

8

15CONFIDENTIAL

Tri-Layer FrameworkTri-Layer Framework

Framework Layers

BaseTest:

• No application dependency

• Basic functionality with base tool

• Any project may use it

Common:

• Project dependent

• Domain specific functionality

• Only project related apps may use it

Additional libraries:

• Solution dependent

• Solution specific functionality

• Example: sensor mocks, parsers, loggers etc.

Core layer

Base Test Additional LibrariesProject Common

Library

16CONFIDENTIAL

Tri-Layer FrameworkTri-Layer Framework

Framework Layers

Structure Models:

• Each screen has their own dedicated

model

• Only element locators and screen specific

properties are stored in these models

• No user actions are to be implemented!

Flow Models:

• The service provider facades

• Test scripts call all the methods from these

models as the test steps

• All user flows are stored in these models

Inter layer

Flow Models Structure Models

12/2/2015

9

17CONFIDENTIAL

Tri-Layer FrameworkTri-Layer Framework

Framework Layers

Test scripts:

• Runnable test scripts

• Implementations of all the ”ready-to-

automate” processed test cases

• Each test step shall directly be called from

facades provided by the flow models

Test layer

Test #1 Test #NTest #2

18CONFIDENTIAL

STRUCTURELOGIC &APP

4. App Logic & Structure

12/2/2015

10

19CONFIDENTIAL

App Logic & StructureApp Logic & Structure

Page Object Model• UI areas that your tests interact with

• Modeled as objects within the test code

• Separate page models

• Both structure and user interactions are

stored in the same class

• Reduces duplicated code

Buttons Textfields Edittexts Images Pickers...

20CONFIDENTIAL

App Logic & StructureApp Logic & Structure

Page Object Model• UI areas that your tests interact with

• Modeled as objects within the test code

• Separate page models

• Both structure and user interactions are

stored in the same class

• Reduces duplicated code

Buttons Textfields Edittexts Images Pickers...

12/2/2015

11

21CONFIDENTIAL

App Logic & StructureApp Logic & Structure

Flow Model Design - Click Username Edittext

- Type Username

- Click Password Edittext

- Type Password

Click Logout Button

Click Continue

Button

Click Login

Button

Main

Screen

Login

Screen

Profile

Screen

Click Back

Button

- Edit Profile

- Click Username Edittext

- Type Username

- Click Cancel button

22CONFIDENTIAL

App Logic & StructureApp Logic & Structure

Screen Structure• Focus is on the objects

• Basically same as a page model without the app logic

included

• It helps determine where you are at in the app

• Builds up the app structure

solo.clickOnView(mainPage.loginButton);

solo.clickOnEditText(loginPage.username);

solo.typeText(loginPage.username, "DarthVader");

solo.clickOnEditText(loginPage.password);

solo.typeText(loginPage.password, "iAMyourF4ther");

solo.clickOnView(loginPage.loginButton);

Assert.equals("Welcome, DonaldDuck" profilePage.Title);

12/2/2015

12

23CONFIDENTIAL

App Logic & StructureApp Logic & Structure

User Flow• Most important user actions are stored in separate flow models

• Corresponds to testing more

• Page structure models are used by the models

• Test scripts call directly from these classes

public login.start() {

solo.clickOnView(mainPage.loginButton));

}

public login.typeUsername(String username) {

solo.clickOnEditText(loginPage.username);

solo.typeText(loginPage.username, username);

}

public login.typePassword(String password) {

solo.clickOnEditText(loginPage.password);

solo.typeText(loginPage.password, password);

}

public login.end() {

solo.clickOnView(loginPage.loginButton);

Assert.equals("Welcome, " + username,

profilePage.Title);

}

24CONFIDENTIAL

App Logic & StructureApp Logic & Structure

Test Script using Flow Models• Methods of Flow Model classes are called

• Code is easy to read

• Test script replaces test case

login.start();

login.typeUsername("DarthVader");

login.typePassword("iAMyourF4ther");

login.end();

12/2/2015

13

25CONFIDENTIAL

Péter Földházi Jr.

[email protected]

Thank You!

Köszönöm!