Search Unity

Question Getting callstack info from Unhandled Logs

Discussion in 'Testing & Automation' started by andrew-fray, Jun 1, 2021.

  1. andrew-fray

    andrew-fray

    Joined:
    Jul 19, 2012
    Posts:
    157
    I'm running test framework 1.1.16 on unity 2019.4.15, all hosted on jenkins. Sometimes a test fails because of an unhandled exception. That's great, I want it to fail! But the nunit xml test output only shows the exception, and no callstack. Eg:

    SetUp : Unhandled log message: '[Exception] NullReferenceException: Object reference not set to an instance of an object'. Use UnityEngine.TestTools.LogAssert.Expect 


    The nunit xml test output includes the logs, but those also have no callstacks.

    When this happens, we have to either re-run the tests locally or (sometimes, when it's an esoteric failure) remote into the jenkins machine to see the callstack.

    Is there a good way to get callstacks out of this message? Is there a better approach to catch this kind of problem?

    Thanks!
     
  2. sbergen

    sbergen

    Joined:
    Jan 12, 2015
    Posts:
    53
    If you archive the full log on CI, you can also search for the logged error in there, and it should include the stack trace (unless you've configured things to not include it).

    Another option would be to listen to
    Application.logMessageReceived[Threaded]
    and explicitly log the stack trace for errors, exceptions and asserts.

    Neither option is really optimal, but I'm not aware of any better ways to do this.