The only unusual thing that I noticed was the Keyboard.current. Are you adding this device somewhere in your test?
Also, do you have any Player Input component in your scenario?
Example for this test:
namespace TestSuite.Features
{
public class MenuTest : InputTestFixture
{
private Keyboard _keyboardDevice;
public override void Setup()
{
base.Setup();
_keyboardDevice = InputSystem.AddDevice<Keyboard>();
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode("Assets/Tests/Features/MenuTest.unity", new LoadSceneParameters(LoadSceneMode.Single));
}
public override void TearDown()
{
GameObject.Find("Player").GetComponent<PlayerInput>().enabled = false;
base.TearDown();
}
[UnityTest]
public IEnumerator OpenMenuTest()
{
// The "Menu" is a simple empty game object inactive in the test scene by default (first image)
Assert.That(GameObject.Find("Menu"), Is.EqualTo(null));
Press(_keyboardDevice.tabKey);
yield return null;
Assert.That(GameObject.Find("Menu").activeInHierarchy, Is.EqualTo(true));
}
}
}
NOTE: The Player object in this scene has a Player Input component to handle all input events.
Hi and sorry for the very late response. Actually it’s just the Tab key. Alphabet keys like “a” “b” “c” is just fine. So it’s not because the Keyboard.current imo