Skip to content

Instantly share code, notes, and snippets.

@henkin
Created May 19, 2021 18:43
Show Gist options
  • Save henkin/09df03c2a6450e4bc1ea454dd1389072 to your computer and use it in GitHub Desktop.
Save henkin/09df03c2a6450e4bc1ea454dd1389072 to your computer and use it in GitHub Desktop.
xunit test dump sorted environment dotnet
using System;
using System.Linq;
using Xunit;
using Xunit.Abstractions;
namespace Jail.Booking.ComponentTests
{
public class DebugTests
{
private readonly ITestOutputHelper _outputHelper;
public DebugTests(ITestOutputHelper outputHelper)
{
_outputHelper = outputHelper;
}
[Fact]
public void DebugTest()
{
_outputHelper.WriteLine("ENVIRONMENT");
var variables = Environment.GetEnvironmentVariables().Keys.Cast<string>().ToList();
variables.Sort();
//.Keys.ToList<string>();
foreach (var envVar in variables)
{
var output = $"{envVar}: '{Environment.GetEnvironmentVariable(envVar)}'";
_outputHelper.WriteLine(output);
}
throw new InvalidCastException(); // to trigger Azure Devops to print output
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment