2

I am having some issues regarding updating an execution status in a zephyr test cycle, this implementation has been present for a year and the failure has only just started occurring, when we run our set of selenium tests, the first test will fail to update the test execution status with the following error:

java.lang.AssertionError: 1 expectation failed.

Expected status code <200> but was <404>.

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:72)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)
at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:499)
at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source)
at io.restassured.internal.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:684)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:193)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:61)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:127)
at io.restassured.specification.ResponseSpecification$statusCode$0.callCurrent(Unknown Source)

After the first test has failed, all other tests successfully update the status, If I put the code into debug and step through the updateTestResult method then it is able to update the status, so it looks like a timing issue in my opinion, however I am not sure how I can handle that delay with our current implementation, Method is below:

public void updateTestResult(boolean isTestFailed) {
    String body;
    if (isTestFailed) {
        body = "{\n" +
                "    \"status\": \"2\"\n" +
                "}";
    } else {
        body = "{\n" +
                "    \"status\": \"1\"\n" +
                "}";
    }
    request = given()
            .auth()
            .preemptive()
            .basic(System.getenv("USER_NAME"), System.getenv("ZAPI_PASSWORD"))
            .header("Accept", "application/json")
            .header("Content-Type", "application/json")
            .body(body);
    response = request.when().put(readPropertiesFile("ZEPHYR_API_URL") + "/execution/" + executionId + "/execute");
    response.then().log().ifError().statusCode(200);
}

Any help would be really appreciated.

D. Barnett
  • 123
  • 6
  • My temporary solution is to wrap the API call in a while loop to give Zephyr API some time to sort itself out and handling the AssertionError in a try catch. This seems to be working now, however I am not happy with the solution, if anyone has any further Ideas I would really appreciate it. – D. Barnett Aug 25 '22 at 15:52

0 Answers0