Jacobvu84 / restassured-serenity

0 stars 0 forks source link

05 - Kịch bản đầu tay với screenplay #5

Open Jacobvu84 opened 4 years ago

Jacobvu84 commented 4 years ago
package com.linecorp.screenplay.features;

import static net.serenitybdd.screenplay.rest.questions.ResponseConsequence.seeThatResponse;

import org.junit.Test;
import org.junit.runner.RunWith;

import net.serenitybdd.junit.runners.SerenityRunner;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.rest.abilities.CallAnApi;
import net.serenitybdd.screenplay.rest.interactions.Get;

@RunWith(SerenityRunner.class)
public class WhenGettingTheApplicationUsingScreenplayStory {

    @Test
    public void shouldBeExecutedSuccesfully() {

        Actor jacob = Actor.named("Jacob")
                         .whoCan(CallAnApi.at("https://api.iextrading.com/1.0"));

        jacob.attemptsTo(Get.resource("/stock/aapl/book"));

        jacob.should(seeThatResponse("the book should be returned", response -> response.statusCode(200)));

    }
}
Jacobvu84 commented 4 years ago

Trong file pom thêm

        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-screenplay-rest</artifactId>
            <version>${serenity.version}</version>
            <scope>test</scope>
        </dependency>