Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4bcf882
Добавлены два новых теста:
Apr 14, 2016
74e6e75
исправление в соответствии с полученными комментариями:
Apr 18, 2016
eeff145
Refactored all WebElement types to HtmlElements
Apr 22, 2016
029201a
Adding additional items to Page Object structure
Apr 24, 2016
a18b6a3
Arranging smoke test pack: marking existing tests and adding new tests
Apr 24, 2016
8086dd2
Adding Regression tests
Apr 26, 2016
5404c22
Updating recording to comments, adding new tests and some refactoring
Apr 29, 2016
8d2fdce
Refactoring: moving PageMethods methods to DefaultSteps
Apr 30, 2016
fba20d3
Fixing error in regexp for time and date
May 2, 2016
d9b45bf
First api auto test using Rest-assured
May 3, 2016
4e52750
Adding second test for Rest assured
May 4, 2016
6e56c15
Added Title and statusCode verification for second test
May 4, 2016
c4fa2c6
Refactoring: removed unused imports and unused getters
May 4, 2016
b6ea52d
Added test cases via Retrofit
May 4, 2016
76151dd
Removed unused Responses classes fields and getters
May 6, 2016
018ae9a
Merging dbClient from master
May 6, 2016
4f510bb
Added test for database and api
May 6, 2016
723d594
Changed matcher in db test
May 7, 2016
13b23a8
Refactored Retfofit test class
May 8, 2016
8189592
Adding getFirstWidget method
May 17, 2016
a87f50e
Adding DbClientRule
May 17, 2016
b3b3b5b
Optimizing POM files for all modules
May 17, 2016
75db792
Creating initial structur for mobile tests
May 17, 2016
fccbd34
Adding MobileDriverRule
May 18, 2016
6b724c5
Adding first test for mobile app Metro
May 22, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions api-tests-module/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>school-2016</artifactId>
<groupId>ru.qatools.school</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>api-tests-module</artifactId>
<name>API Tests</name>

<dependencies>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-junit-adaptor</artifactId>
</dependency>
<dependency>
<groupId>ru.qatools.school</groupId>
<artifactId>dbclient-module</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.matchers</groupId>
<artifactId>collection-matchers</artifactId>
<version>1.3</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ru.qatools.school.Responses;

/**
* @author ava1on
*/
public class CitiesResponse {

public CitiesResponse() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.qatools.school.Responses;

/**
* @author ava1on
*/
public class SuggestResponse {
private int id;

public SuggestResponse(int id){
this.id = id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ru.qatools.school.Responses;

/**
* @author ava1on
*/
public class TemperatureValues {
private double value;

public TemperatureValues(double value) {
this.value = value;
}

public double getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ru.qatools.school.Responses;

/**
* @author ava1on
*/
public class WeatherResponse {
private TemperatureValues[] temperatures;

public WeatherResponse(TemperatureValues[] temperatures) {
this.temperatures = temperatures;
}

public TemperatureValues[] getTemperatures() {
return temperatures;
}

public Double recalculateCelsiusToFahrenheit(){
return (this.getTemperatures()[0].getValue()*9/5+32);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package ru.qatools.school.apitests;

import org.apache.http.HttpStatus;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import ru.qatools.school.DbClient;
import ru.qatools.school.rules.DbClientRule;
import ru.yandex.qatools.allure.annotations.Title;

import java.util.List;

import static com.jayway.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static ru.qatools.school.data.Constants.*;

/**
* @author ava1on
*/
public class DbAPITest {
private DbClient dbClient;

@Rule
public DbClientRule dbClientRule = new DbClientRule();

@Before
public void setupDbConnection(){
dbClient = dbClientRule.getDbClient();
}

@Test
@Title("Списки городов, полученные через API и Database, должны совпадать")
public void apiResponseShouldMatchDatabaseData(){
List<Integer> ids =
given()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все красивяшки со сдвигами пропадут при автоформате. Не парься с этим

.baseUri(BASE_URL)
.param(QUERY_PARAMETER, CITYNAME_PART)
.when()
.get(SUGGEST_REQUEST)
.then()
.assertThat().statusCode(HttpStatus.SC_OK)
.and().extract().body().path("id");
assertThat("Полученные через API данные не соответствуют Database", ids,
is(dbClient.getCitiesByNamePart(CITYNAME_PART)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package ru.qatools.school.apitests;

import org.apache.http.HttpStatus;
import org.junit.Test;
import ru.qatools.school.Responses.CitiesResponse;
import ru.qatools.school.Responses.WeatherResponse;
import ru.yandex.qatools.allure.annotations.Title;

import static com.jayway.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.is;
import static ru.qatools.school.data.Constants.*;

/**
* @author ava1on
*/
public class RestAssuredAPITests {

@Test
@Title("Должны получить заданное в параметре количество городов в ответе")
public void shouldReturnRequestedNumberOfCities(){
CitiesResponse[] citiesArray =
given().
baseUri(BASE_URL).
param(LIMIT_PARAMETER, LIMIT_VALUE).
when().
get(CITIES_REQUEST).
then().statusCode(HttpStatus.SC_OK).
and().extract().
body().as(CitiesResponse[].class);
assertThat("Неверное количество городов в ответе", citiesArray.length, is(LIMIT_VALUE));
}

@Test
@Title("Значение температуры по шкале Фаренгейта должно соответствовать значению по шкале Цельсия")
public void shouldReturnCompatibleTemperatureValuesForCelsiusAndFahrenheit(){
WeatherResponse weatherResponse =
given().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

переноси точку на новую строку - так читаемее - понятно что это продолжение чейна, а не новый вызов, когда переводишь взгляд на новую строку

baseUri(BASE_URL).
param(CITY_PARAMETER, CITY_VALUE).
when().
get(WEATHER_REQUEST).
then().statusCode(HttpStatus.SC_OK).
and().extract().
body().as(WeatherResponse.class);
assertThat("Значение температуры не правильно переведено из шкалы Цельсия в шкалу Фаренгейта",
weatherResponse.getTemperatures()[2].getValue(),
is(closeTo(weatherResponse.recalculateCelsiusToFahrenheit(), TEMPERATURE_ERROR)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package ru.qatools.school.apitests;

import org.apache.http.HttpStatus;
import org.junit.BeforeClass;
import org.junit.Test;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import ru.qatools.school.Responses.CitiesResponse;
import ru.qatools.school.Responses.WeatherResponse;
import ru.qatools.school.interfaces.Cities;
import ru.qatools.school.interfaces.Weather;
import ru.yandex.qatools.allure.annotations.Title;

import java.io.IOException;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.closeTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static ru.qatools.school.data.Constants.*;

/**
* @author ava1on
*/
public class RetrofitAPITests {

private static Retrofit retrofit;

@BeforeClass
public static void initRetrofit(){
retrofit = new Retrofit.Builder().baseUrl(BASE_URL).addConverterFactory(GsonConverterFactory.create()).build();
}

@Test
@Title("Должны получить заданное в параметре количество городов в ответе")
public void shouldReturnRequestedNumberOfCities() throws IOException{
Cities cities = retrofit.create(Cities.class);
Response<List<CitiesResponse>> response = cities.citiesList(LIMIT_VALUE).execute();
assertThat("Код ответа неверный", response.code(), is(HttpStatus.SC_OK));
assertThat("Неверное количество городов в ответе", response.body(), hasSize(LIMIT_VALUE));
}

@Test
@Title("Значение температуры по шкале Фаренгейта должно соответствовать значению по шкале Цельсия")
public void shouldReturnCompatibleTemperatureValuesForCelsiusAndFahrenheit() throws IOException{
Weather weather = retrofit.create(Weather.class);
Response<WeatherResponse> response = weather.weather(CITY_PARAMETER, null).execute();
assertThat("Код ответа неверный", response.code(), is(HttpStatus.SC_OK));
assertThat("Значение температуры не правильно переведено из шкалы Цельсия в шкалу Фаренгейта",
response.body().getTemperatures()[2].getValue(),
is(closeTo(response.body().recalculateCelsiusToFahrenheit(), TEMPERATURE_ERROR)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ru.qatools.school.data;

/**
* @author ava1on
*/
public class Constants {
public static final String BASE_URL = "http://weather.lanwen.ru/api/";
public static final String LIMIT_PARAMETER = "limit";
public static final String CITIES_REQUEST = "cities";
public static final int LIMIT_VALUE = 3;
public static final String WEATHER_REQUEST = "weather";
public static final String CITY_PARAMETER = "city";
public static final String CITY_VALUE = "Saint Petersburg";
public static final double TEMPERATURE_ERROR = 0.1;
public static final String REGION_PARAMETER = "region";
public static final String SUGGEST_REQUEST = "suggest";
public static final String QUERY_PARAMETER = "query";
public static final String CITYNAME_PART = "Saint";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ru.qatools.school.interfaces;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
import ru.qatools.school.Responses.CitiesResponse;

import java.util.List;

import static ru.qatools.school.data.Constants.LIMIT_PARAMETER;

/**
* @author ava1on
*/
public interface Cities {
@GET("cities")
Call<List<CitiesResponse>> citiesList(@Query(LIMIT_PARAMETER) int limitValue);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ru.qatools.school.interfaces;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
import ru.qatools.school.Responses.WeatherResponse;

import static ru.qatools.school.data.Constants.CITY_PARAMETER;
import static ru.qatools.school.data.Constants.REGION_PARAMETER;

/**
* @author ava1on
*/
public interface Weather {
@GET("weather")
Call<WeatherResponse> weather(@Query(CITY_PARAMETER) String city, @Query(REGION_PARAMETER) String region);
}
2 changes: 0 additions & 2 deletions commons-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
<dependency>
<groupId>com.tngtech.java</groupId>
<artifactId>junit-dataprovider</artifactId>
<version>1.10.4</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package ru.qatools.school.mobiletests;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import ru.qatools.school.rules.MobileDriverRule;
import ru.qatools.school.screens.MainScreen;
import ru.qatools.school.screens.SelectStationScreen;
import ru.qatools.school.steps.mobilesteps.MobileSteps;
import ru.yandex.qatools.allure.annotations.Title;

/**
* @author ava1on
*/
public class MetroMobileTests {

private MobileSteps mobileSteps;
private final String STATION1 = "Arbatskaya";
private final String STATION2 = "Borisovo";
private final int MINIMUM_TRAVEL_TIME = 10;

@Rule
public MobileDriverRule mobileDriverRule = new MobileDriverRule();

@Before
public void initsteps(){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase в названии метода

mobileSteps = new MobileSteps(mobileDriverRule.getDriver());
}

@Test
@Title("Время в пути должно быть больше мимимального")
public void travelTimeShouldBeGreaterThanMinimum(){
mobileSteps.fillStationField(onMainScreen().getFrom(), STATION1);
mobileSteps.fillStationField(onMainScreen().getTo(), STATION2);
mobileSteps.travelTimeShouldBeGreaterThen(MINIMUM_TRAVEL_TIME);
}

private MainScreen onMainScreen(){
return new MainScreen(mobileDriverRule.getDriver());
}

private SelectStationScreen onSelectionStationScreen(){
return new SelectStationScreen(mobileDriverRule.getDriver());
}
}
Loading