boost ui tests

40
Boost UI tests

Upload: alex-fruzenshtein

Post on 14-Jul-2015

725 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Boost UI tests

Boost UI tests

Page 2: Boost UI tests

REST reason?SPA?

Page 3: Boost UI tests

The market dictates the rules

Page 4: Boost UI tests
Page 5: Boost UI tests

UI should beindependent

of a server-side

Page 6: Boost UI tests

RESTful approach

Page 7: Boost UI tests
Page 8: Boost UI tests

Let’s think about an applike about a set of

resources

Page 9: Boost UI tests

Sample app model

Page 10: Boost UI tests

Standard operations

CREATEREADUPDATEDELETE

Page 11: Boost UI tests

All modern web appsuse HTTPand JSON

Page 12: Boost UI tests

Mapping of HTTP requests

GET /landlords/

[{ id: 0001, name: “Joe”, age: 48}, id: 0002, name: “Sam”, age: 34}, id: 0003, name: “Peter”, age: 31}

]

Page 13: Boost UI tests

Mapping of HTTP requests

GET /landlords/002

Status: 200

{ id: 0002, name: “Sam”, age: 34}

Page 14: Boost UI tests

Mapping of HTTP requests

PUT /landlords/002

Request body:{ id: 0002, name: “Bob”, age: 57}

Response:Status: 200

Page 15: Boost UI tests

Mapping of HTTP requests

PUT /landlords/009

Request body:{ id: 0002, name: “Bob”, age: 57}

Response:Status: 404

Page 16: Boost UI tests

Mapping of HTTP requests

POST /landlords/

Request body:{ name: “Kate”, age: 28}

Response:Status: 201

Page 17: Boost UI tests

Mapping of HTTP requests

DELETE /landlords/001 Response:Status: 200

Page 18: Boost UI tests

Mapping of HTTP requests

GET /landlords/003/realty

[{ id: 0001, type: “house”, address: Cool str 3}, id: 0002, type: “apartment”, address: Team road 7}

]

Page 19: Boost UI tests

All business logic can beinvoked from any

platform

Page 20: Boost UI tests
Page 21: Boost UI tests

REST-assuredby JayWay

Page 22: Boost UI tests

@Testpublic void getTest() {

given().contentType(ContentType.JSON).queryParam("api_key", "special-key").queryParam("neo4j", "true").queryParam("friends", "false")

.when().get("/users")

.then().statusCode(200).body("[0].name", equalTo("Modestine Carce"));

}

GET

Page 23: Boost UI tests

@Testpublic void postTest() {

given().contentType(ContentType.JSON).queryParam("api_key", "special-key").queryParam("neo4j", "true").queryParam("name", "Ketty")

.when().post("/users")

.then().statusCode(200).body("[0].name", equalTo("Ketty"));

}

POST

Page 24: Boost UI tests

@Testpublic void putTest() {

given().contentType(ContentType.JSON).queryParam("api_key", "special-key").queryParam("neo4j", "true").queryParam("name", "Bob").pathParameter("id", "a353fc219a0934d8410dd938805sde")

.when().post("/users/{id}")

.then().statusCode(200).body("name", equalTo("Bob"));

}

PUT

Page 25: Boost UI tests

@Testpublic void deleteTest() {

given().contentType(ContentType.JSON).queryParam("api_key", "special-key").queryParam("neo4j", "true").pathParameter("id", "a353fc219a0934d8410dd938805sde")

.when().delete("/users/{id}")

.then().statusCode(200).body("message", equalTo("deleted user"));

}

DELETE

Page 26: Boost UI tests

● Easy to read● Given-When-Then● Very fast● Technical background not required

Summary

Page 27: Boost UI tests

REST-assured&

UI tests

Page 28: Boost UI tests

WTF?

Page 29: Boost UI tests
Page 30: Boost UI tests
Page 31: Boost UI tests
Page 32: Boost UI tests

● Extra time for static resources● Extra time for REST calls● Complexity of some actions● Maintenance efforts● Long execution time (1, 2)

UI testing

Page 33: Boost UI tests

● Interaction with UI● End to end testing

UI testing

Page 34: Boost UI tests

Testing Pyramid

Page 35: Boost UI tests

Testing Pyramid+

API

Page 36: Boost UI tests

How to combinate?

Page 37: Boost UI tests

Prepare test data

Page 38: Boost UI tests

Decrease a numberof UI tests

Page 39: Boost UI tests

Cool story, bro

Page 40: Boost UI tests

@FruzenshteinAlexey Zvolinskiy