Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Testing MonoBehaviour without calling Reset/OnValidate functions

Discussion in 'Testing & Automation' started by hyagogow, Dec 5, 2021.

  1. hyagogow

    hyagogow

    Joined:
    Apr 25, 2014
    Posts:
    26
    I want to unit test a MonoBehaviour class.
    Every time I instantiate one (using AddComponent on Setup phase) two MonoBehaviour functions are called:
    1. Reset()
    2. OnValidate()
    Would be possible to somehow create MonoBehaviours without calling those functions?

    P.S: if possible, i don't want to create a separate class with all business logic. I just want to put them inside the MonoBehaviour class and test it.