Set individual formatters with key-value based environment variables#769
Merged
gasparnagy merged 32 commits intomainfrom Aug 17, 2025
Merged
Set individual formatters with key-value based environment variables#769gasparnagy merged 32 commits intomainfrom
gasparnagy merged 32 commits intomainfrom
Conversation
…verts the input to an override to be applied via Environment Variable.
…now uses key-value pairs, such as --logger "formatter;name=message;outputFilePath=foo.ndjson". The infrastructure is now in place to set multiple loggers on the command line, but that is not yet working.
…derive from a base class.
Added description of how to configure the formatters using the --logger command line.
Co-authored-by: obligaron <obligaron@live.com>
…ovider for consistency
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces formatter-specific environment variable configuration support for Reqnroll formatters. The changes allow users to configure individual formatters using simple key-value pairs in environment variables like REQNROLL_FORMATTERS_HTML, which take precedence over the existing JSON-based REQNROLL_FORMATTERS variable.
- Adds a new
KeyValueEnvironmentConfigurationResolverto parse formatter-specific environment variables - Refactors the existing environment configuration resolver to focus specifically on JSON format
- Updates the configuration provider to handle both JSON and key-value environment variable overrides with proper precedence
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
docs/reporting/reqnroll-formatters.md |
Updates documentation to mention environment variable configuration option |
docs/installation/formatter-configuration.md |
Adds comprehensive documentation for formatter-specific environment variables with examples |
Tests/Reqnroll.RuntimeTests/Formatters/Configuration/KeyValueEnvironmentConfigurationResolverTests.cs |
New test file with comprehensive test coverage for the key-value environment configuration resolver |
Tests/Reqnroll.RuntimeTests/Formatters/Configuration/JsonEnvironmentConfigurationResolverTests.cs |
Renames and updates tests for the JSON-specific environment configuration resolver |
Tests/Reqnroll.RuntimeTests/Formatters/Configuration/CucumberConfigurationTests.cs |
Updates test to work with refactored configuration provider dependencies |
Tests/Reqnroll.RuntimeTests/EnvironmentWrapperStub.cs |
Adds implementation for new GetEnvironmentVariables method |
Tests/Reqnroll.Formatters.Tests/MessagesCompatibilityTestBase.cs |
Updates test setup to use refactored configuration provider |
Reqnroll/Infrastructure/DefaultDependencyProvider.cs |
Updates DI container registrations for the refactored configuration resolvers |
Reqnroll/Formatters/Configuration/KeyValueEnvironmentConfigurationResolver.cs |
New resolver implementation for parsing key-value environment variables |
Reqnroll/Formatters/Configuration/JsonEnvironmentConfigurationResolver.cs |
Refactored from generic environment resolver to focus on JSON format |
Reqnroll/Formatters/Configuration/IKeyValueEnvironmentConfigurationResolver.cs |
New interface for key-value environment configuration resolver |
Reqnroll/Formatters/Configuration/IJsonEnvironmentConfigurationResolver.cs |
New interface for JSON environment configuration resolver |
Reqnroll/Formatters/Configuration/IFormattersConfigurationResolverBase.cs |
Removes deprecated interfaces |
Reqnroll/Formatters/Configuration/IFileBasedConfigurationResolver.cs |
New interface for file-based configuration resolver |
Reqnroll/Formatters/Configuration/FormattersConfigurationResolverBase.cs |
Minor formatting change |
Reqnroll/Formatters/Configuration/FormattersConfigurationProvider.cs |
Updates to use new resolver interfaces and handle null values for disabled formatters |
Reqnroll/Formatters/Configuration/FormattersConfigurationConstants.cs |
Adds constant for formatter environment variable prefix |
Reqnroll/Formatters/Configuration/FileBasedConfigurationResolver.cs |
Updates interface implementation |
Reqnroll/EnvironmentAccess/IEnvironmentWrapper.cs |
Adds method signature for getting environment variables by prefix |
Reqnroll/EnvironmentAccess/EnvironmentWrapper.cs |
Implements method to retrieve environment variables by prefix |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Reqnroll/Formatters/Configuration/KeyValueEnvironmentConfigurationResolver.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…tionResolver.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 What's changed?
Taking out generic stuff from #697 and applied for standard environment variable handling, i.e. now the formatters can be configured with specific environment variables, like
REQNROLL_FORMATTERS_HTML, with simple key-value settings:These environment variables can also be used to enable a formatter with default settings:
$env:REQNROLL_FORMATTERS_HTML = 'true'or disable them (if they have been configured in config file:$env:REQNROLL_FORMATTERS_HTML = 'false'.These environment variables have higher precedence than the JSON based
REQNROLL_FORMATTERS, so override them.Also made sure that the formatter names and the setting names are treated case insensitive, e.g.
$env:REQNROLL_FORMATTERS_HTML = 'OUTputFilePath=test.html'sets theoutputFilePathsetting of thehtmlformatter.⚡️ What's your motivation?
Provide a simple way of configuring formatters from shell.
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
📋 Checklist:
This text was originally taken from the template of the Cucumber project, then edited by hand. You can modify the template here.