Skip to content

test API - #1

Open
GuruQuality wants to merge 4 commits into
masterfrom
test_API
Open

test API#1
GuruQuality wants to merge 4 commits into
masterfrom
test_API

Conversation

@GuruQuality

Copy link
Copy Markdown
Owner

No description provided.

.statusCode(201);
}

//1. get /student/{id} возвращает JSON студента с указанным ID и заполненным именем, если такой есть в базе, код 200.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Лучше это поместить в @DisplayName для каждого автотеста вместо комментария

Student student =
RestAssured.given()
.baseUri("http://localhost:8080")
//.header("content-type", "application\\json")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

удалить стоит этот ненужный закоментаренный код

.baseUri("http://localhost:8080")
//.header("content-type", "application\\json")
.contentType(ContentType.JSON)
//.body(studentJSON)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вот здесь можно добавить .log().all() для логирования всего запроса, при необходимости

.when()
.get("/student/" + EXIST_STUDENT_ID)
.then()
.statusCode(200)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Вот здесь можно добавить .log().all() для логирования всего ответа, при необходимости, а строчку System.out.println(student); тогда можно удалить


//4. post /student обновляет студента в базе, если студент с таким ID ранее был, при этом имя заполнено, код 201.
@Test
public void updateStudent() throws JsonProcessingException {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

idea подсказывает нам, выделяя светло-серым, что код неиспользуемый, можно удалить, проще всего щёлкнув на синий текст из подсказки среды разработки, когда подвести курсор к выделенному слову

Image

.post("/student/")
.then()
.statusCode(201);
System.out.println("UpdatedStudent: " + updatedStudent);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Следует через GET запрос проверить в этом автотесте, что произошёл успешный апдейт имени студента.
Вывод на экран ожидаемого значения студента никакой проверки за собой, по сути, не несёт. Вместо вывода на экран следует использовать логирование запроса и ответа, при необходимости, как писал в комментарии выше.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants