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

Enhancement: Disable a filter/Set a filter to None #1761

Open
technigirl opened this issue Jan 3, 2024 · 0 comments
Open

Enhancement: Disable a filter/Set a filter to None #1761

technigirl opened this issue Jan 3, 2024 · 0 comments

Comments

@technigirl
Copy link

technigirl commented Jan 3, 2024

I have an enhancement suggestion. I would like to be able to set a filter to do nothing; below I will explain the reason for this.

In my code, I need to be able to select different filters at runtime. The code is as follows:

    public static List<Filter> getRestAssuredFilters() {

        //Pass in the log level via system property, e.g. -DlogLevel=ERROR
        // Set a default
        if ((logLevel == null) || logLevel.isBlank()) {
            logLevel = "ERROR";
        }
        if (logLevel.equals("ERROR")) {
            restAssuredFilters.add(new ErrorLoggingFilter());
        }
        else if (logLevel.equals("DEBUG")){
            restAssuredFilters.add(new RequestLoggingFilter(LogDetail.ALL));
            restAssuredFilters.add(new ResponseLoggingFilter(LogDetail.ALL));
        }
        return restAssuredFilters;
    }
}

The log level can be selected by a system property as noted in the comment above.
However, there are times when I would like to suppress all logging, or suppress the global filter in favor of a local log statement that is created for an individual test. For example, when I want to turn off the Error logging for tests which purposely return an error code, and instead set log().ifValidationFails().

There seems to be, as far as I can tell, no way to do this in Rest Assured.

In summary, I would like to be able to set a filter to None (or null or something similar), effectively disabling the filter so that I can do something else inside of a test.

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

1 participant