作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在关注 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 )
但是当我运行我的代码时,我总是得到:
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)
我有以下测试步骤:
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 相关的依赖项
<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>
这是我的 fork git hub 仓库:https://github.com/jarvcol/CarnivalTest/tree/addApiTesting
对此有什么想法吗???
最佳答案
因为您没有使用匹配的 serenity-core
依赖项。尝试在 pom.xml
中添加以下依赖项并更新项目:
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>2.0.34</version>
</dependency>
关于java - net.serenitybdd.core.exceptions.SerenityManagedException : SERENITY_DISABLE_REST_CALLS_AFTER_FAILURES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54472152/
我正在关注 Serenity BDD 测试 API 的许多示例。主要是 ( https://github.com/serenity-bdd/serenity-core/blob/master/sere
我是一名优秀的程序员,十分优秀!