diff --git a/src/LfMerge.Core.Tests/SRTestEnvironment.cs b/src/LfMerge.Core.Tests/SRTestEnvironment.cs index 34edff62..86a1286f 100644 --- a/src/LfMerge.Core.Tests/SRTestEnvironment.cs +++ b/src/LfMerge.Core.Tests/SRTestEnvironment.cs @@ -97,9 +97,11 @@ protected override void Dispose(bool disposing) if (CleanUpTestData) { StopMongo(); } else { - Console.WriteLine($"Leaving Mongo container {MongoContainerId} around to examine data on failed test."); - Console.WriteLine($"It is listening on {Settings.MongoDbHostNameAndPort}"); - Console.WriteLine($"To delete it, run `docker stop {MongoContainerId} ; docker rm {MongoContainerId}`."); + if (MongoContainerId is not null) { + Console.WriteLine($"Leaving Mongo container {MongoContainerId} around to examine data on failed test."); + Console.WriteLine($"It is listening on {Settings.MongoDbHostNameAndPort}"); + Console.WriteLine($"To delete it, run `docker stop {MongoContainerId} ; docker rm {MongoContainerId}`."); + } } } base.Dispose(disposing);