LogAssert.ignoreFailingMessages does not work, still 'Unhandled log message'

My test fails with an ‘Unhandled log message’ error.
However, I expect this unhandled log message and it is unrelated to the test case.

I tried to disable these checks with LogAssert.ignoreFailingMessages = true. But it does not work. The test still fails due to an unrelated log message.
I also tried to exepct this log message: ```
LogAssert.Expect(LogType.Exception, new Regex(@“.*”))


So, how can I ignore unwanted and unrelated log message checks in test?

Example:

```csharp
[OneTimeSetUp]
public void OneTimeSetUp()
{
    Debug.Log("OneTimeSetUp");
    Debug.Log("ignoring failing messages");
    // Does not help, still getting "Unhandled log message: '[Exception] Exception: SteamApi_Init returned false. Steam isn't running, couldn't find Steam, AppId is ureleased, Don't own AppId.'."
    LogAssert.ignoreFailingMessages = true;

    Debug.Log("Expecting all kind of exceptions");
    // Does not help, now failing because "OneTimeSetUp: Expected log did not appear: [Exception] Regex: .*"
    LogAssert.Expect(LogType.Exception, new Regex(@".*"));

    // Normal OneTimeSetup for the test cases...
}

For now, I worked around this issue by turning the exception into a warning when running in the editor:

if (Application.isEditor)
            {
                // Steam is not expected to run in the editor. Only log a warning.
                try
                {
                    SteamClient.Init(MySteamAppId);
                }
                catch (Exception ex)
                {
                    Debug.LogWarning(ex.Message);
                    return;
                }
            }
            else
            {
                SteamClient.Init(MySteamAppId);
                if (!SteamClient.IsValid)
                {
                    throw new SteamException("Steam client not valid");
                }
            }

Still, I would appreciate if Unity would fix these log checks.

LogAssert.ignoreFailingMessages = true seems to work when placed in a method annotated with [UnityTest].

Still, I think that logs should not cause a test failure by default.

2 Likes