Search Unity

Bug RegexOptions.IgnoreCase not working with LogAssert.Expect

Discussion in 'Testing & Automation' started by ryanmccauley211, Apr 22, 2023.

  1. ryanmccauley211

    ryanmccauley211

    Joined:
    Jul 25, 2018
    Posts:
    6
    I am trying to test an error log is triggered but it doesn't seem to pick this up as a match

    Code (CSharp):
    1. LogAssert.Expect(LogType.Error, new Regex("unexpected null value",
    2. , RegexOptions.IgnoreCase));

    I am using the following string "Unexpected null value for image". It works when I use the regex

    Code (CSharp):
    1. "(?i)unexpected null value"
    Just wondering if I am missing something or if RegexOptions are not supported in LogAssert?
     
  2. sbergen

    sbergen

    Joined:
    Jan 12, 2015
    Posts:
    53
    I once ran into a similar issue, debugged it, and found out that the regex is actually stored as a simple string (using
    ToString()
    on the regex) at some point inside the test framework. This means that no regex options are supported.