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
27 commits
Select commit Hold shift + click to select a range
0002484
Two web autotests
OneginES Apr 14, 2016
d15a93a
Add test for choose another city
OneginES Apr 15, 2016
2911e2a
Fix some bugs...
OneginES Apr 15, 2016
7a275c0
Fix code according to comments
OneginES Apr 17, 2016
34245ce
Rewrite part of code according to comments
OneginES Apr 19, 2016
3b25d1d
Change maven encoding to UTF-8.
OneginES Apr 20, 2016
f94c32d
Merge with init for TestPalma
OneginES Apr 20, 2016
dbff25c
Add some new tests, some tests and steps refactoring.
OneginES Apr 22, 2016
66e302d
Add step for waiting until changing element is ready.
OneginES Apr 23, 2016
eeb3d13
Add some tests. Add some objects in pageObject.
OneginES Apr 23, 2016
fba2f18
Add some tests. Add some steps. Add some objects in pageObject.
OneginES Apr 24, 2016
3eee981
Add "import ru.yandex.qatools.allure.annotations.TestCaseId"
OneginES Apr 25, 2016
d465cdd
Change logic construction to CITY2_BEGIN constant.
OneginES Apr 25, 2016
70b4812
Test class is divided into two classes: smoke and regression.
OneginES Apr 25, 2016
4ca431a
Correction of mistakes
OneginES Apr 25, 2016
5690d0a
Add clickOn() for several times.
OneginES Apr 25, 2016
d00ccdc
everyItem is added
OneginES Apr 26, 2016
ae32181
New module. Add dependencies. Add tests from presentation.
OneginES Apr 27, 2016
14c98f3
Refactor project structure. Add two autotests for API.
OneginES Apr 30, 2016
343dc7d
Merge with DB
OneginES Apr 30, 2016
7f9112f
API + DB Tests
OneginES May 2, 2016
dbcab3f
Refactoring according to @lanwen and @bluedogseyes reviews.
OneginES May 4, 2016
d3f3631
rm apiData to apidata
OneginES May 5, 2016
3260326
Link to Dockerfile
OneginES May 8, 2016
6f8d2a0
Merge two classes in one WebTest class.
OneginES May 10, 2016
4dab412
MobileTest
OneginES May 18, 2016
86154da
Fix test for time greater than 1h.
OneginES May 19, 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Practice of automation school 2016

See all info in repo [autoschool/autoschool.github.io](https://github.com/autoschool/autoschool.github.io)

See Dockerfile in repo [OneginES/Docker](https://github.com/OneginES/Docker)
46 changes: 46 additions & 0 deletions api-tests-module/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>school-2016</artifactId>
<groupId>ru.qatools.school</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>api-tests-module</artifactId>

<name>API Module</name>

<dependencies>
<dependency>
<groupId>ru.qatools.school</groupId>
<artifactId>steps-module</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ru.qatools.school</groupId>
<artifactId>dbclient-module</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.matchers</groupId>
<artifactId>collection-matchers</artifactId>
<version>1.3</version>
</dependency>
</dependencies>

<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</reporting>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package ru.qatools.school.apitests;

import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.specification.RequestSpecification;
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.apidata.SuggestResp;
import ru.qatools.school.apidata.WeatherResp;
import ru.qatools.school.tp.TPInformerRule;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.TestCaseId;
import ru.yandex.qatools.allure.annotations.Title;

import java.util.List;

import static com.jayway.restassured.RestAssured.given;
import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static ru.yandex.qatools.matchers.collection.HasSameItemsAsListMatcher.hasSameItemsAsList;

/**
* @author onegines (Eugene Kirienko)
*/
public class RestAssuredTest {

private static final String MAIN_PAGE = "http://weather.lanwen.ru/";
private static final String BASE_PATH = "api";

private static final String CITYNAME = "Chita";
private static final String CITYNAMEBEGIN = "Saint";
private static final String CITYNAMEPART = "ain";

private RequestSpecification reqSpec;

private DbClient dbClient;

@Rule
public TPInformerRule tms = new TPInformerRule("onegines");

@Before
public void init() {
dbClient = new DbClient();

reqSpec = new RequestSpecBuilder().build()
.baseUri(MAIN_PAGE)
.basePath(BASE_PATH);
}

@After
public void close() {
dbClient.close();
}

@Test
@Features("Suggest")
@Title("Должны получить код 400 после отправки запроса саджеста без параметров")
@TestCaseId("53")
public void shouldGetErrorCode400AfterSendNoQueryToSuggest() throws Exception {
given().spec(reqSpec)
.get("suggest")
.then().assertThat()
.statusCode(HttpStatus.SC_BAD_REQUEST);
}

@Test
@Features("Suggest")
@Title("Должны получить список городов, содержащих в названии строку из запроса")
@TestCaseId("42")
public void shouldGetSuggestsContainsPartOfName() throws Exception {
given().spec(reqSpec)
.param("query", CITYNAMEBEGIN)
.get("suggest")
.then().assertThat()
.statusCode(HttpStatus.SC_OK)
.and().body("name", everyItem(containsString(CITYNAMEBEGIN)));
}

@Test
@Features("Suggest")
@Title("Должны совпадать списки (от API и DB) саджестов, содержащих в названии города строку из запроса")
@TestCaseId("75")
public void shouldMatchSuggestsFromApiAndDb() throws Exception {

List<SuggestResp> respApi = asList(
given().spec(reqSpec)
.param("query", CITYNAMEPART)
.expect().statusCode(HttpStatus.SC_OK)
.get("suggest")
.as(SuggestResp[].class)
);

List<SuggestResp> respDb = dbClient.getSuggestCitiesByNamePart(CITYNAMEPART);

assertThat("Списки из API и DB должны совпадать", respApi, hasSameItemsAsList(respDb));

}

@Test
@Features("Weather")
@Title("Должны получить погоду в городе с названием, указанным в запросе")
@TestCaseId("55")
public void shouldGetWeatherWithCityName() throws Exception {

WeatherResp resp =
given().spec(reqSpec)
.param("city", CITYNAME)
.expect().statusCode(HttpStatus.SC_OK)
.get("weather")
.as(WeatherResp.class);

assertThat("Неправильный город", resp.getCity(), is(CITYNAME));

}

@Test
@Features("Weather")
@Title("Должны получить погоду в городе с названием '0'")
@TestCaseId("60")
public void shouldGetWeatherWithCityName0() throws Exception {

WeatherResp resp =
given().spec(reqSpec)
.param("city", "0")
.expect().statusCode(HttpStatus.SC_OK)
.get("weather")
.as(WeatherResp.class);

assertThat("Неправильный город", resp.getCity(), is("0"));

}

@Test
@Features("Weather")
@Title("Должны получить код 400 после отправки запроса погоды без параметров")
@TestCaseId("65")
public void shouldGetErrorCode400AfterSendNoQueryToWeather() throws Exception {
given().spec(reqSpec)
.get("weather")
.then().assertThat()
.statusCode(HttpStatus.SC_BAD_REQUEST);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
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 retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import ru.qatools.school.DbClient;
import ru.qatools.school.apidata.SuggestResp;
import ru.qatools.school.apidata.WeatherApi;
import ru.qatools.school.apidata.WeatherResp;
import ru.qatools.school.tp.TPInformerRule;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Title;

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

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static ru.yandex.qatools.matchers.collection.HasSameItemsAsListMatcher.hasSameItemsAsList;

/**
* @author onegines (Eugene Kirienko)
*/
public class RetrofitTest {

private static final String MAIN_PAGE = "http://weather.lanwen.ru/";
private static final String CITYNAMEBEGIN = "Saint";
private static final String CITYNAMEPART = "ain";

private WeatherApi weatherApi;
private DbClient dbClient;

private Retrofit retrofit = new Retrofit.Builder()
.baseUrl(MAIN_PAGE)
.addConverterFactory(GsonConverterFactory.create())
.build();

@Rule
public TPInformerRule tms = new TPInformerRule("onegines");

@Before
public void init() {
weatherApi = retrofit.create(WeatherApi.class);
dbClient = new DbClient();
}

@After
public void close() {
dbClient.close();
}

@Test
@Features("Suggest")
@Title("Должны получить код 400 после отправки запроса саджеста без параметров")
//@TestCaseId("53")
public void shouldGetErrorCode400AfterSendNoQueryToSuggest() throws IOException {

Response<List<SuggestResp>> resp = weatherApi.suggest().execute();

assertThat("Неправильный код ответа", resp.code(), is(HttpStatus.SC_BAD_REQUEST));

}

@Test
@Features("Suggest")
@Title("Должны получить список городов, содержащих в названии строку из запроса")
//@TestCaseId("42")
public void shouldGetSuggestsContainsPartOfName() throws IOException {

Response<List<SuggestResp>> resp = weatherApi.suggest(CITYNAMEBEGIN).execute();

assertThat("Request status different from expected", resp.code(), is(HttpStatus.SC_OK));
assertThat("Все города должны содержать строку из запроса", resp.body(), everyItem(hasProperty("name", containsString(CITYNAMEBEGIN))));

}

@Test
@Features("Suggest")
@Title("Должны совпадать списки (от API и DB) саджестов, содержащих в названии города строку из запроса")
//@TestCaseId("75")
public void shouldMatchSuggestsFromApiAndDb() throws IOException {

Response<List<SuggestResp>> respApi = weatherApi.suggest(CITYNAMEPART).execute();
List<SuggestResp> respDb = dbClient.getSuggestCitiesByNamePart(CITYNAMEPART);

assertThat("Неправильный код ответа", respApi.code(), is(HttpStatus.SC_OK));
assertThat("Списки из API и DB должны совпадать", respApi.body(), hasSameItemsAsList(respDb));

}

@Test
@Features("Weather")
@Title("Должны получить код 400 после отправки запроса погоды без параметров")
//@TestCaseId("65")
public void shouldGetErrorCode400AfterSendNoQueryToWeather() throws IOException {

Response<WeatherResp> resp = weatherApi.weather().execute();

assertThat("Неправильный код ответа", resp.code(), is(HttpStatus.SC_BAD_REQUEST));

}


}
1 change: 0 additions & 1 deletion commons-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@
</plugin>
</plugins>
</reporting>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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 by onegines (Eugene Kirienko)
*/
public class MobileTests {

private static final String STATION_1 = "Arbatskaya";
private static final String STATION_2 = "Borisovo";
private static final int MIN_TIME = 10;

private MobileSteps mobSteps;

@Rule
public MobileDriverRule mobileDriverRule = new MobileDriverRule();

// @Rule
// public TPInformerRule tms = new TPInformerRule("onegines");

@Before
public void initSteps() {
mobSteps = new MobileSteps(mobileDriverRule.getDriver());
}

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

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

@Test
@Title("Время в пути от Арбатской до Борисово должно быть больше 10 минут")
// @TestCaseId("##")
public void shouldSeeAddWidgetButtonOnPageWithNoQuery() {
mobSteps.tapOn(onMainScreen().fromField());
mobSteps.enterText(onSelectStationScreen().stationNameField(), STATION_1);
mobSteps.tapOn(onSelectStationScreen().firstResult());

mobSteps.tapOn(onMainScreen().toField());
mobSteps.enterText(onSelectStationScreen().stationNameField(), STATION_2);
mobSteps.tapOn(onSelectStationScreen().firstResult());

mobSteps.shouldSeeTimeMoreThan(onMainScreen().timeField(), MIN_TIME);
}

}
Loading