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

BP-1166: Configure integration tests to capture log statements from t… #33

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

zsrdjan
Copy link
Contributor

@zsrdjan zsrdjan commented Jul 16, 2024

…he production code (in WebApplication factory use Server.PreserveExecutionContext = true)

…he production code (in WebApplication factory use Server.PreserveExecutionContext = true)
_isUserAuthenticated = isUserAuthenticated;

// needed so that log statements from the Api appear in the test console runner
Server.PreserveExecutionContext = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for the log statements of the production code to appear in the tests.

restrictedToMinimumLevel: LogEventLevel.Warning,
formatProvider: CultureInfo.InvariantCulture,
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}");
loggerConfiguration.ConfigureSerilogForIntegrationTests();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to shared extension class so that same settings can be used in the scheduler.

// this allows serilog log statements to appear in the test console runner
// e.g. database sql queries (issued by DbContext) can be observed this way in the test
loggerConfiguration.WriteTo.Console(
LogEventLevel.Information,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Information log level we can see what is happening in our code. However some noise appears, which makes reading logs harder. The noise is supressed below.

@zsrdjan zsrdjan merged commit 5ee704b into master Jul 16, 2024
13 checks passed
@zsrdjan zsrdjan deleted the features/BP-1166-log-in-tests branch July 16, 2024 15:06
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

Successfully merging this pull request may close these issues.

2 participants