diff --git a/Content.IntegrationTests/Tests/LogErrorTest.cs b/Content.IntegrationTests/Tests/LogErrorTest.cs new file mode 100644 index 0000000000..17ae6e5f97 --- /dev/null +++ b/Content.IntegrationTests/Tests/LogErrorTest.cs @@ -0,0 +1,33 @@ +using System.Threading.Tasks; +using NUnit.Framework; +using Robust.Shared.Configuration; +using Robust.Shared.Log; +using Robust.UnitTesting; + +namespace Content.IntegrationTests.Tests; + +public sealed class LogErrorTest +{ + /// + /// This test ensures that error logs cause tests to fail. + /// + [Test] + public async Task TestLogErrorCausesTestFailure() + { + await using var pairTracker = await PoolManager.GetServerClient(); + var server = pairTracker.Pair.Server; + var client = pairTracker.Pair.Client; + + var cfg = server.ResolveDependency(); + + // Default cvar is properly configured + Assert.That(cfg.GetCVar(RTCVars.FailureLogLevel), Is.EqualTo(LogLevel.Error)); + + // Warnings don't cause tests to fail. + await server.WaitPost(() => Logger.Warning("test")); + + // But errors do + await server.WaitPost(() => Assert.Throws(() => Logger.Error("test"))); + await client.WaitPost(() => Assert.Throws(() => Logger.Error("test"))); + } +}