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

Allow standard Reporter overrides #973

Closed
tschlat opened this issue Sep 7, 2023 · 1 comment · Fixed by #975
Closed

Allow standard Reporter overrides #973

tschlat opened this issue Sep 7, 2023 · 1 comment · Fixed by #975

Comments

@tschlat
Copy link
Collaborator

tschlat commented Sep 7, 2023

User story
As an active user and developer within the Citrus framework ecosystem, where I contribute additional features built upon the foundation of Citrus, I am seeking the capability to customize and override Citrus default logging mechanisms. For example I want to be able to provide a more sophisticated logging via a specific LoggingReporter. I am explicitly seeking for a solution that allows me to replace default logging behaviour, so that I do not get things reported twice. In addition, I want to avoid bean overriding in Spring.

Additional context
At present, Spring's standard reporters are managed by the ReporterConfig class. Overriding these reporter beans typically involves setting spring.main.allow-bean-definition-overriding=true plus using the @primary annotation on the replacement bean. However, this approach is discouraged by Spring due to potential side effects. To address this issue more elegantly, there is a need for an enhanced solution that facilitates overriding while minimizing any undesirable consequences.

The standard reports in focus are:
LoggingReporter
HtmlReporter
JUnitReporter

The LoggingReporter serves a multifaceted purpose beyond the scope of mere test result reporting. Consequently, removing it entirely is not a viable option. In contrast, both the HtmlReporter and JUnitReporter already offer a mechanism for disabling their functionality. Hence, I propose that introducing a disablement option for the standard LoggingReporter would effectively meet the requirements. This would allow users to replace standard reporters with custom logic or other reporting solutions using a simple configuration snippet like the following:

@Bean
public CustomLoggingReporter customLoggingReporter(@Qualifier("citrusLoggingReporter") LoggingReporter citrusLoggingReporter) {
    citrusLoggingReporter.setEnabled(false);
    return new CustomLoggingReporter();
}
@tschlat
Copy link
Collaborator Author

tschlat commented Sep 7, 2023

Implementing this I realized, that a replacement is quite cumbersome, as for example the LoggingReporter is also responsible for Logging other aspects of the test execution.

Therefore I have slightly adjusted my user story.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment