Search Unity

Question Integration Testing for Exception thrown in Awake

Discussion in 'Testing & Automation' started by glynhanmer, Jan 6, 2017.

  1. glynhanmer

    glynhanmer

    Joined:
    May 16, 2016
    Posts:
    2
    I would like to test that a component of mine throws an exception for certain conditions during Awake(). When I use the Unity Test Tools Test Component, though, the test fails because of the exception, even though "Expect exception" and "Succeed when exception is thrown" are both checked. The test passes when I throw the same exception in Start, though.

    Am I testing wrong? or perhaps implementing bad design? I can't find documentation on the Test Component to say anything about not catching exceptions thrown during Awake().

    Does anybody have any idea why this might be?
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    I think this is just a limitation in the integration test runner. Personally, i find the current implementation of integration tests cumbersome and confusing.

    Can you describe how you've setup your integration test? i could try to reproduce the same structure and test it myself.
     
  3. glynhanmer

    glynhanmer

    Joined:
    May 16, 2016
    Posts:
    2
    Hi again,
    Sorry for the late reply!


    I've a Test Component with:
    Expect exception: true
    Succeed when exception thrown: true

    and a GameObject that throws an exception during the Awake() method.

    The integration test fails with 'Failed with exception' message :eek: