首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >net.serenitybdd.core.exceptions.SerenityManagedException: SERENITY_DISABLE_REST_CALLS_AFTER_FAILURES

net.serenitybdd.core.exceptions.SerenityManagedException: SERENITY_DISABLE_REST_CALLS_AFTER_FAILURES
EN

Stack Overflow用户
提问于 2019-02-01 10:42:44
回答 1查看 5.7K关注 0票数 2

我正在关注许多serenity bdd测试API的例子。主要(https://github.com/serenity-bdd/serenity-core/blob/master/serenity-screenplay-rest/src/test/java/net/serenitybdd/screenplay/rest/examples/WhenRetrievingUserDetails.java)

但是当我运行我的代码时,我总是得到:

代码语言:javascript
复制
TEST FAILED WITH ERROR: User attempts to recover the password
---------------------------------------------------------------------
[main] ERROR net.serenitybdd.core.Serenity - TEST FAILED AT STEP Rest
[main] ERROR net.serenitybdd.core.Serenity - SERENITY_DISABLE_REST_CALLS_AFTER_FAILURES

net.serenitybdd.core.exceptions.SerenityManagedException: SERENITY_DISABLE_REST_CALLS_AFTER_FAILURES

    at net.serenitybdd.rest.utils.RestExecutionHelper.restCallsAreDisabled(RestExecutionHelper.java:28)
    at net.serenitybdd.rest.utils.RestSpecificationFactory.getInstrumentedRequestSpecification(RestSpecificationFactory.java:105)
    at net.serenitybdd.rest.utils.RestDecorationHelper.decorate(RestDecorationHelper.java:20)
    at net.serenitybdd.rest.SerenityRest.given(SerenityRest.java:220)
    at net.serenitybdd.screenplay.rest.interactions.RestInteraction.rest(RestInteraction.java:32)
    at net.serenitybdd.screenplay.rest.interactions.Post$$EnhancerByCGLIB$$6437c6d9.CGLIB$rest$3(<generated>)
    at net.serenitybdd.screenplay.rest.interactions.Post$$EnhancerByCGLIB$$6437c6d9$$FastClassByCGLIB$$49fc3d71.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at net.thucydides.core.steps.BaseMethodRunner.invokeMethod(BaseMethodRunner.java:10)
    at net.thucydides.core.steps.NormalMethodRunner.invokeMethodAndNotifyFailures(NormalMethodRunner.java:20)
    at net.thucydides.core.steps.StepInterceptor.runNormalMethod(StepInterceptor.java:361)
    at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:132)
    at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:68)
    at net.serenitybdd.screenplay.rest.interactions.Post$$EnhancerByCGLIB$$6437c6d9.rest(<generated>)
    at net.serenitybdd.screenplay.rest.interactions.Post.performAs(Post.java:24)
    at net.serenitybdd.screenplay.rest.interactions.Post$$EnhancerByCGLIB$$6437c6d9.CGLIB$performAs$0(<generated>)
    at net.serenitybdd.screenplay.rest.interactions.Post$$EnhancerByCGLIB$$6437c6d9$$FastClassByCGLIB$$49fc3d71.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at net.thucydides.core.steps.StepInterceptor.invokeMethod(StepInterceptor.java:449)
    at net.thucydides.core.steps.StepInterceptor.executeTestStepMethod(StepInterceptor.java:434)
    at net.thucydides.core.steps.StepInterceptor.runTestStep(StepInterceptor.java:409)
    at net.thucydides.core.steps.StepInterceptor.runOrSkipMethod(StepInterceptor.java:150)
    at net.thucydides.core.steps.StepInterceptor.testStepResult(StepInterceptor.java:137)
    at net.thucydides.core.steps.StepInterceptor.intercept(StepInterceptor.java:68)
    at net.serenitybdd.screenplay.rest.interactions.Post$$EnhancerByCGLIB$$6437c6d9.performAs(<generated>)
    at net.serenitybdd.screenplay.Actor.perform(Actor.java:100)
    at net.serenitybdd.screenplay.Actor.attemptsTo(Actor.java:84)
    at jarv.serenity.carnival.features.steps.steps.RecoverUserNameSteps.he_attemps_to_recover_password(RecoverUserNameSteps.java:40)
    at ✽.he sends the required information to recover his password(src/test/resources/features/ProfileManagement.feature:7)

我有以下测试步骤:

代码语言:javascript
复制
package jarv.serenity.carnival.features.steps.steps;
import net.serenitybdd.screenplay.rest.abilities.CallAnApi;
import net.serenitybdd.screenplay.rest.interactions.Post;
import cucumber.api.java.Before;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import net.serenitybdd.screenplay.Actor;
import static org.hamcrest.Matchers.equalTo;
import static net.serenitybdd.screenplay.rest.questions.ResponseConsequence.seeThatResponse;

public class RecoverUserNameSteps {

    private String theRestApiBaseUrl = "https://www.carnival.com/ProfileManagement/api/v1.0";
    private Actor jorge;
    private String userName;

    @Before
    public void set_the_test(){
        jorge = Actor.named("Jorge, learning serenity rest").whoCan(CallAnApi.at(theRestApiBaseUrl));
    }

    @Given("^Jorge is not a registered user$")
    public void jorge_is_not_registered() throws Throwable {
        //TODO: Investigate what should be done here???
    }

    @Given("^he wants to recover his password$")
    public void jorge_wants_to_recover_the_password() throws Throwable {
        //I am setting this as blank cause the service to retrieve the password will only failed if request parameter is blank!!!
        //When sending any other kind of string response is 202 Accepted, only blanks generate 400 Bad request
        //Test may need to be changed to recover username instead, which has more options to get the error code
        userName = "";
    }

    @When("^he sends the required information to recover his password$")
    public void he_attemps_to_recover_password() throws Throwable {
        //TODO: Create Object Model for Request Body and send it. Anyway example is way too simple to do that and I am running out of time Julian.
        jorge.attemptsTo(
                Post.to("/Accounts/Password/Forgot")
                        .with(request -> request.header("Content-Type", "application/json")
                                .body("{\"username\": \"joe\"}")
                        )
        );
    }

    @Then("^he should be informed that operation could not be done$")
    public void he_must_see_a_failed_response() throws Throwable {
        jorge.should(
                seeThatResponse( "Recover for password was denied",
                        response -> response.statusCode(400)
                )
        );
    }
}

这是我的maven与rest相关的依赖项。

代码语言:javascript
复制
<dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-rest-assured</artifactId>
            <version>2.0.34</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-screenplay-rest</artifactId>
            <version>2.0.34</version>
            <scope>test</scope>
</dependency>

这是我的分支git集线器存储库:https://github.com/jarvcol/CarnivalTest/tree/addApiTesting

对此有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2019-02-12 23:17:42

因为您没有使用匹配的serenity-core依赖项。尝试在pom.xml中添加以下依赖项并更新项目:

代码语言:javascript
复制
<dependency>
  <groupId>net.serenity-bdd</groupId>
  <artifactId>serenity-core</artifactId>
  <version>2.0.34</version>
</dependency>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54472152

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档