#Unity Testing Framework with Input System Tests

1 messages · Page 1 of 1 (latest)

rain forge
#

With Testing Framework how do I properly do something like hold w key or hold left stick up for a few seconds?

inputTest.Click(keyboard.wKey);
seems to not throw any errors but also only shortly clicks it as far as I can tell(?)

The problem is when I try a UnityTest like this:

    [UnityTest]
    public IEnumerator PlayerTest()
        yield return new WaitForSeconds(0.6f);
        inputTest.Press(keyboard.wKey);
        yield return new WaitForSeconds(2);
        inputTest.Release(keyboard.wKey);
        yield return new WaitForSeconds(0.1f);
    }

it throws an error:


UnityEngine.InputSystem.InputAction:ReadValue<UnityEngine.Vector2> ()
RocketController:Thrusters () (at Assets/Scripts/Player/PlayerController.cs:75)
RocketController:FixedUpdate () (at Assets/Scripts/Player/PlayerController.cs:56)

Any ideas?

#

Similiar error for gamepad using
inputTest.Move(gamePad.leftStick, Vector2.up);
also
inputTest.Set(gamePad.leftStick, Vector2.up);

rain forge
#

Okay so removing
"inputTest.Setup();"
seems to have done it UnityChanThink

#

left them as comments so you can see what i mean

    [SetUp]
    public void Setup()
    {
        //inputTest.Setup();
        gamePad = InputSystem.AddDevice<Gamepad>();
    }

    [TearDown] 
    public void TearDown()
    {
        //inputTest.TearDown();
    }```

If someone can explain it please?? 😄 otherwise I'm good
<https://discussions.unity.com/t/using-unity-inputs-inputtestfixture-to-drive-player-character-in-a-functional-test/940923/7> (Link where i found the setup from)