Search Unity

Resolved Is something wrong with using LogAssert.Expect for LogType.Exception? (Solved: Wrong LogType)

Discussion in 'Testing & Automation' started by Tuss, Nov 6, 2019.

  1. Tuss

    Tuss

    Joined:
    Mar 22, 2016
    Posts:
    2
    Hello, Testing & Automation people!

    Is something wrong with using LogAssert.Expect for LogType.Exception?
    Or am I crazy here?

    Simple example below:

    [Test]
    public void NetworkManager_TestsTest()
    {
    LogAssert.Expect(LogType.Exception, "test");
    Debug.Assert(false, "test");
    }

    I continue to receive the following error:
    Unhandled log message: '[Assert] test'. Use UnityEngine.TestTools.LogAssert.Expect


    No matter in what order I rearrange when to Expect the Assertion, before, after, even before AND after...

    Thoughts?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    You are expecting a log of type Exception, and then log an Assertion (LogAssert).
    Instead, you should log the message using: Debug.LogException.
     
    Tuss likes this.
  3. Tuss

    Tuss

    Joined:
    Mar 22, 2016
    Posts:
    2
    Ahhh.... I see now. I must have missed that somehow. Thank you very much! : )

    Upon switching it, it now works fine.
     
    liortal likes this.