boost ui tests

Post on 14-Jul-2015

725 Views

Category:

Engineering

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Boost UI tests

REST reason?SPA?

The market dictates the rules

UI should beindependent

of a server-side

RESTful approach

Let’s think about an applike about a set of

resources

Sample app model

Standard operations

CREATEREADUPDATEDELETE

All modern web appsuse HTTPand JSON

Mapping of HTTP requests

GET /landlords/

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

]

Mapping of HTTP requests

GET /landlords/002

Status: 200

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

Mapping of HTTP requests

PUT /landlords/002

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

Response:Status: 200

Mapping of HTTP requests

PUT /landlords/009

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

Response:Status: 404

Mapping of HTTP requests

POST /landlords/

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

Response:Status: 201

Mapping of HTTP requests

DELETE /landlords/001 Response:Status: 200

Mapping of HTTP requests

GET /landlords/003/realty

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

]

All business logic can beinvoked from any

platform

REST-assuredby JayWay

@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

@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

@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

@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

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

Summary

REST-assured&

UI tests

WTF?

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

UI testing

● Interaction with UI● End to end testing

UI testing

Testing Pyramid

Testing Pyramid+

API

How to combinate?

Prepare test data

Decrease a numberof UI tests

Cool story, bro

@FruzenshteinAlexey Zvolinskiy

top related