Skip to content

Conversation

@gasparnagy
Copy link
Contributor

@gasparnagy gasparnagy commented Aug 16, 2025

🤔 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:

$env:REQNROLL_FORMATTERS_HTML = 'outputFilePath=test.html'

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 the outputFilePath setting of the html formatter.

⚡️ What's your motivation?

Provide a simple way of configuring formatters from shell.

🏷️ What kind of change is this?

  • ⚡ New feature (non-breaking change which adds new behaviour)

♻️ Anything particular you want feedback on?

📋 Checklist:

  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.

This text was originally taken from the template of the Cucumber project, then edited by hand. You can modify the template here.

clrudolphi and others added 29 commits July 30, 2025 11:52
…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.
Added description of how to configure the formatters using the --logger command line.
@gasparnagy gasparnagy requested a review from Copilot August 16, 2025 20:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 KeyValueEnvironmentConfigurationResolver to 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.

@gasparnagy gasparnagy marked this pull request as ready for review August 16, 2025 20:52
@gasparnagy gasparnagy requested a review from clrudolphi August 16, 2025 20:53
@gasparnagy gasparnagy changed the title Formatter environment variable Set individual formatters with key-value based environment variables Aug 16, 2025
Copy link
Contributor

@clrudolphi clrudolphi left a comment

Choose a reason for hiding this comment

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

Looks good

@gasparnagy gasparnagy merged commit 5887506 into main Aug 17, 2025
13 of 14 checks passed
@gasparnagy gasparnagy deleted the formatter-environment-variable branch August 17, 2025 15:02
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.

3 participants