citrusframework / citrus

Framework for automated integration tests with focus on messaging integration
https://citrusframework.org
Apache License 2.0
456 stars 134 forks source link

Allow standard Reporter overrides #973

Closed tschlat closed 1 year ago

tschlat commented 1 year ago

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 commented 1 year ago

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.