From ed2d79287b553db2237d320acd3579bd5f728556 Mon Sep 17 00:00:00 2001 From: Guga Date: Thu, 5 Oct 2023 10:10:47 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20feat:=20Cucumber=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95(#487)=20(#489)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: 학교 생성 스텝 추가 및 반영 * test: log all 삭제 * test: 축제 생성 테스트에 학교 생성 과정 포함 --- .../festago/acceptance/steps/ExampleStep.java | 29 ++++++++++++++----- .../acceptance/steps/ExampleStep2.java | 2 +- .../test/resources/features/example.feature | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/backend/src/test/java/com/festago/acceptance/steps/ExampleStep.java b/backend/src/test/java/com/festago/acceptance/steps/ExampleStep.java index e9dfde186..d1bad34cd 100644 --- a/backend/src/test/java/com/festago/acceptance/steps/ExampleStep.java +++ b/backend/src/test/java/com/festago/acceptance/steps/ExampleStep.java @@ -9,6 +9,8 @@ import com.festago.festival.dto.FestivalDetailResponse; import com.festago.festival.dto.FestivalResponse; import com.festago.festival.dto.FestivalsResponse; +import com.festago.school.dto.SchoolCreateRequest; +import com.festago.school.dto.SchoolResponse; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.restassured.RestAssured; @@ -30,38 +32,51 @@ public void login() { .contentType(ContentType.JSON) .body(new RootAdminInitializeRequest(password)) .post("admin/initialize") - .then().log().all() + .then() .statusCode(200); ExtractableResponse response = RestAssured.given() .contentType(ContentType.JSON) .body(new AdminLoginRequest("admin", password)) .post("admin/login") - .then().log().all() + .then() .extract(); - String token = "token"; - cucumberClient.addAuthToken(response.cookie(token)); + cucumberClient.addAuthToken(response.cookie("token")); } @Given("축제를 생성하고") public void given() { - + SchoolResponse schoolResponse = (SchoolResponse) cucumberClient.getData("schoolResponse"); FestivalCreateRequest request = new FestivalCreateRequest("푸우 축제", LocalDate.now(), - LocalDate.now().plusDays(1), "thumnail"); + LocalDate.now().plusDays(1), "thumnail", schoolResponse.id()); FestivalResponse response = RestAssured.given() .contentType(ContentType.JSON) .cookie("token", cucumberClient.getToken()) .body(request) .post("admin/festivals") .then() - .log().all() .extract() .body() .as(FestivalResponse.class); cucumberClient.addData("festivalData", response); } + @Given("{string}를 생성하고") + public void makeSchool(String schoolName) { + SchoolCreateRequest request = new SchoolCreateRequest(schoolName, "domain.com"); + SchoolResponse response = RestAssured.given() + .contentType(ContentType.JSON) + .cookie("token", cucumberClient.getToken()) + .body(request) + .post("admin/schools") + .then() + .extract() + .body() + .as(SchoolResponse.class); + cucumberClient.addData("schoolResponse", response); + } + @Then("축제가 있다") public void then() { FestivalDetailResponse response = (FestivalDetailResponse) cucumberClient.getData("searchResult"); diff --git a/backend/src/test/java/com/festago/acceptance/steps/ExampleStep2.java b/backend/src/test/java/com/festago/acceptance/steps/ExampleStep2.java index defa0022f..b54fd25d1 100644 --- a/backend/src/test/java/com/festago/acceptance/steps/ExampleStep2.java +++ b/backend/src/test/java/com/festago/acceptance/steps/ExampleStep2.java @@ -18,7 +18,7 @@ public void given() { FestivalDetailResponse festivalInfo = RestAssured.given() .when() .get("festivals/{festivalId}", response.id()) - .then().log().all() + .then() .extract() .as(FestivalDetailResponse.class); cucumberClient.addData("searchResult", festivalInfo); diff --git a/backend/src/test/resources/features/example.feature b/backend/src/test/resources/features/example.feature index eedeab8a9..39f4eb86f 100644 --- a/backend/src/test/resources/features/example.feature +++ b/backend/src/test/resources/features/example.feature @@ -2,6 +2,7 @@ Feature: 축제 생성 Scenario: 성공 Given 로그인을 한 상태에서 + Given "테코대학교"를 생성하고 Given 축제를 생성하고 When 축제를 검색하면 Then 축제가 있다