Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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: