How to trigger Update() method in tests?

I am trying to trigger the Update() method of one my components in a unit test:

[UnityTest]
public IEnumerator SweetTest()
{
    GameObject gameObject = new GameObject();
    ElevatorController elevator = gameObject.AddComponent<ElevatorController>();

    // Skip frame to trigger ElevatorController.Update()
    yield return null;

But my Update() method is never called :confused:

Any ideas?

Put the content of the update in a separate method, and then in Update you will only have that SeparateMethod() called. Now just call SeparateMethod() in the test. Make sure it is public. Also if you need it called multiple times in your test, ust put it in a for loop :slight_smile: Good luck with your game

It needs to be a PlayMode test, as the Update method is only invoked in PlayMode tests and not in EditMode.