Harden tests and update runtime config docs
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
- проверка схемы ответа через Json Schema Validator.
|
||||
|
||||
3. Негативные сценарии:
|
||||
- `POST /pet` с malformed JSON возвращает ошибку;
|
||||
- `POST /pet` с malformed JSON возвращает `4xx`;
|
||||
- `GET /pet/{id}` для удаленного/несуществующего id возвращает `404`;
|
||||
- `GET /pet/findByStatus` с невалидным статусом возвращает пустой список.
|
||||
|
||||
@@ -57,6 +57,7 @@ mvn verify
|
||||
## Параметры запуска
|
||||
- `base.uri` (по умолчанию `https://petstore.swagger.io`)
|
||||
- `base.path` (по умолчанию `/v2`)
|
||||
- значения читаются из `System properties` во время выполнения тестов.
|
||||
|
||||
Пример:
|
||||
```bash
|
||||
|
||||
@@ -2,20 +2,17 @@ package ru.otus.petstore.config;
|
||||
|
||||
public final class TestConfig {
|
||||
|
||||
private static final String BASE_URI =
|
||||
System.getProperty("base.uri", "https://petstore.swagger.io");
|
||||
|
||||
private static final String BASE_PATH =
|
||||
System.getProperty("base.path", "/v2");
|
||||
private static final String DEFAULT_BASE_URI = "https://petstore.swagger.io";
|
||||
private static final String DEFAULT_BASE_PATH = "/v2";
|
||||
|
||||
private TestConfig() {
|
||||
}
|
||||
|
||||
public static String getBaseUri() {
|
||||
return BASE_URI;
|
||||
return System.getProperty("base.uri", DEFAULT_BASE_URI);
|
||||
}
|
||||
|
||||
public static String getBasePath() {
|
||||
return BASE_PATH;
|
||||
return System.getProperty("base.path", DEFAULT_BASE_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,10 @@ public class PetNegativeScenariosTest {
|
||||
""";
|
||||
|
||||
int status = petService.createPetRaw(brokenJson).statusCode();
|
||||
MatcherAssert.assertThat(status, Matchers.anyOf(Matchers.is(400), Matchers.is(405), Matchers.is(500)));
|
||||
MatcherAssert.assertThat(
|
||||
status,
|
||||
Matchers.allOf(Matchers.greaterThanOrEqualTo(400), Matchers.lessThan(500))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,11 +28,13 @@ public class PetPositiveScenariosTest {
|
||||
|
||||
try {
|
||||
Response createResponse = petService.createPetExpectSuccess(pet);
|
||||
assertThat(createResponse.path("id"), equalTo((int) petId));
|
||||
Number createdPetId = createResponse.path("id");
|
||||
assertThat(createdPetId.longValue(), equalTo(petId));
|
||||
assertThat(createResponse.path("name"), equalTo(pet.getName()));
|
||||
|
||||
Response getResponse = retryGetPetById(petService, petId);
|
||||
assertThat(getResponse.path("id"), equalTo((int) petId));
|
||||
Number fetchedPetId = getResponse.path("id");
|
||||
assertThat(fetchedPetId.longValue(), equalTo(petId));
|
||||
assertThat(getResponse.path("name"), equalTo(pet.getName()));
|
||||
} finally {
|
||||
petService.deletePetIfExists(petId);
|
||||
|
||||
Reference in New Issue
Block a user