11namespace TUnit . Core . Interfaces ;
22
3+ /// <summary>
4+ /// Defines an interface for accessing configuration values within the TUnit testing framework.
5+ /// </summary>
6+ /// <remarks>
7+ /// <para>
8+ /// The configuration system provides a way to influence test execution through external settings.
9+ /// </para>
10+ /// <para>
11+ /// Configuration values can come from various sources, including:
12+ /// <list type="bullet">
13+ /// <item><description>Command-line arguments passed to the test runner</description></item>
14+ /// <item><description>Environment variables</description></item>
15+ /// <item><description>Configuration files (like appsettings.json)</description></item>
16+ /// </list>
17+ /// </para>
18+ /// <para>
19+ /// This interface is primarily accessed through the static <see cref="TestContext.Configuration"/> property,
20+ /// making configuration values available to tests without requiring dependency injection.
21+ /// </para>
22+ /// <para>
23+ /// Configuration keys can include nested paths using a colon separator (e.g., "Section:Key").
24+ /// </para>
25+ /// </remarks>
26+ /// <example>
27+ /// <code>
28+ /// [Test]
29+ /// public async Task ConfigurationExample()
30+ /// {
31+ /// // Access a configuration value
32+ /// string? logLevel = TestContext.Configuration.Get("LogLevel");
33+ ///
34+ /// // Use a nested configuration path
35+ /// string? apiUrl = TestContext.Configuration.Get("Services:ApiService:Url");
36+ ///
37+ /// // Check if a feature flag is enabled
38+ /// bool isFeatureEnabled = TestContext.Configuration.Get("FeatureFlags:NewFeature") == "true";
39+ /// }
40+ /// </code>
41+ /// </example>
342public interface IConfiguration
443{
44+ /// <summary>
45+ /// Retrieves a configuration value from the test execution environment by key.
46+ /// </summary>
47+ /// <param name="key">The configuration key to look up.</param>
48+ /// <returns>
49+ /// The configuration value associated with the specified key, or <c>null</c> if the key is not found.
50+ /// </returns>
51+ /// <remarks>
52+ /// This method provides access to configuration values that can be set via command-line arguments,
53+ /// environment variables, or configuration files used in the test execution context.
54+ /// The configuration system is used by the TUnit testing framework to provide runtime
55+ /// configuration to tests and test infrastructure components.
56+ /// </remarks>
57+ /// <example>
58+ /// <code>
59+ /// // Accessing a configuration value in a test
60+ /// string? logLevel = TestContext.Configuration.Get("LogLevel");
61+ /// if (logLevel == "Verbose")
62+ /// {
63+ /// // Enable verbose logging for this test
64+ /// }
65+ /// </code>
66+ /// </example>
567 string ? Get ( string key ) ;
668}
0 commit comments