Search Unity

Bug Timeout that occurs during [UnitySetUp] makes the test succeed

Discussion in 'Testing & Automation' started by SimonToop, Apr 29, 2020.

  1. SimonToop

    SimonToop

    Joined:
    Mar 27, 2017
    Posts:
    2
    Hi all,

    I'm running into an issue here:
    In PlayTest mode, I've put a timeout to my [UnityTest]. That test is part of a [TestFixture]. If a timeout occurs during the test, it makes the test fail. However, if the timeout occurs during the [UnitySetUp] phase, the timeout will bail out correctly but will mark the test as PASSED.

    Here is the repro snippet:
    Code (CSharp):
    1.  
    2.     [TestFixture]
    3.     class TimeoutTest
    4.     {
    5.         [UnitySetUp]
    6.         public IEnumerator SetupBase()
    7.         {
    8.             yield return new WaitForSeconds(20);
    9.         }
    10.  
    11.         [UnityTest, Timeout(10000)]
    12.         public IEnumerator TimeoutShouldFail()
    13.         {
    14.             yield return new WaitForSeconds(20);
    15.         }
    16.     }
    Timeout is 10s and Setup should takes 20s to finish. This means that the timeout will occurs during the UnitySetUp. The test will be marked as PASSED.

    If you change line 8 to:
    Code (CSharp):
    1. yield return new WaitForSeconds(5);
    Then the timeout will occurs during the UnityTest and the test will be marked as FAILED.

    Unity: 2019.3.7f1
    Test Framework: 1.1.13

    Can someone tell me if this is the intended behavior here or the test should FAILED if the timeout occurs during UnitySetUp ?

    Thank you very much,

    Simon