Search code examples
spockrest-assuredallure

How to Remove Logging Output from Allure 2


I have Java/Groovy/Spock tests and Allure 2 report. I use allure.Step() annotation to describe all steps that I want to see in Allure report. For example:

def "some test"() {
  when: "do some request"
  Request.getRequest()
}

class Request {
  @Step("GET https://some.request")
  static Response getRequest() {
    return given().log().all()
            .filter(new AllureRestAssured())
            .when()
            .get(conf.url())
  }
}

In that case I see two basically same blocks in report:

  • one beautiful block step with finely formatted request and response due to AllureRestAssured()
  • one ugly block with the same unformatted request and response info due to .log().all() console output.

Is there a way to remove all console output from Allure report and leave only methods that have @Step annotation?


Solution

  • Ma college have found a solution. Separate object with all required RestAssured filters:

    class BeforeAll {
        BeforeAll() {
            filters(new AllureRestAssured(), new RequestLoggingFilter(), new ResponseLoggingFilter())
        }
    }
    

    And call this object on test or extended Specification:

    static BeforeAll beforeAll = new BeforeAll()