Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Logging and Response Logging filters displaying the same log in a loop #1780

Open
yuriespinosa opened this issue Apr 7, 2024 · 1 comment

Comments

@yuriespinosa
Copy link

I'm using the log filter for Request and Response in my beforeEach, to be functional in all tests of this class.

This class has 3 tests, each time a new test is run, the previous test log is displayed in sequence with the new test log, reaching the end of the test with a huge queue of requests/responses in my console.

Am I applying these filters wrong?

@BeforeEach
  public void beforeEach(){
    RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter());
    baseURI = "http://165.xxx.xxx.xxx";
    basePath = "/lojinha";
}

RestAssured version 5.4.0

@lucas-nguyen-17
Copy link
Contributor

Since the filter is a LinkedList, not a Set, then every time @BeforeEach method run, it will add new RequestLoggingFilter(), new ResponseLoggingFilter() to list of filter--> you will see my duplicated logs.

To fix this.

RestAssured.filters(new RequestLoggingFilter(), new ResponseLoggingFilter());

changes to

RestAssured.replaceFiltersWith(new RequestLoggingFilter(), new ResponseLoggingFilter());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants