I need to run some code only if I'm running from within the TeamCity test launcher. What's the easiest way to detect this?
Check if TEAMCITY_VERSION environment variable is defined.
Another approach is to use NUnit categories.
Based on the comment below this code should be able to check if the test is being run by teamcity:
private static bool IsOnTeamCity()
{
string environmentVariableValue = Environment.GetEnvironmentVariable("TEAMCITY_VERSION");
if (!string.IsNullOrEmpty(environmentVariableValue))
{
return true;
}
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With