Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug LogAssert.Expect bug

Discussion in 'Testing & Automation' started by liortal, Mar 31, 2023.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    We recently faced a weird bug with LogAssert.Expect, wanted to know if it's reported, or solved in newer versions of the UTF package.

    One of the developers on the team used the method in the following way:
    Code (CSharp):
    1. LogAsset.Expect(LogType.Error, Arg.Any<string>());
    * Arg.Any<T> is an API for argument matching (part of NSubstitute).

    The test was executed as part of our CI pipeline, without any errors, but it caused an empty XML report to be produced (we run the tests using the TestRunnerApi from editor code, then generate the report and save it to disk).

    I'm wondering if this is a known issue? I suspect that under the hood, some internal exception is thrown as part of execution which causes this behaviour.

    Here's a full test case (similar to what our real test), if you wish to check it out:
    Code (CSharp):
    1. [Test]
    2. public void Test_DoesntProduceReport()
    3. {
    4.     var x = 42;
    5.  
    6.     LogAsset.Expect(LogType.Error, Arg.Any<string>());
    7.  
    8.     Assert.AreEqual(42, x);
    9. }
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Any comments on this ?