TestEnvironment Class

Provides information about the environment the test suite is running in.

public static class TestEnvironment

Methods

NameDescription
IsGlobalizationInvariant()Determines whether the application runs in invariant globalization mode.
IsOnContinuousIntegration(ContinuousIntegrationEnvironments)Determines whether the test suite runs on one of the specified continuous integration environments.
IsOnGitHubActions()Determines whether the test suite runs on GitHub Actions.

IsGlobalizationInvariant()

TestEnvironment.cs

Determines whether the application runs in invariant globalization mode.

public static bool IsGlobalizationInvariant()

Returns

bool true when invariant globalization mode is enabled; otherwise false.

Remarks

This mirrors how the runtime resolves the setting: the System.Globalization.Invariant switch, which is set by the InvariantGlobalization MSBuild property, takes precedence over the DOTNET_SYSTEM_GLOBALIZATION_INVARIANT environment variable.

IsOnContinuousIntegration(ContinuousIntegrationEnvironments)

TestEnvironment.cs

Determines whether the test suite runs on one of the specified continuous integration environments.

public static bool IsOnContinuousIntegration(ContinuousIntegrationEnvironments environment)

Parameters

environment ContinuousIntegrationEnvironments
The continuous integration environments to test for.

Returns

bool true when the test suite runs on any of the specified environments; otherwise false.

IsOnGitHubActions()

TestEnvironment.cs

Determines whether the test suite runs on GitHub Actions.

public static bool IsOnGitHubActions()

Returns

bool true when the test suite runs on GitHub Actions; otherwise false.