I am currently trying to create unit tests for a game, and in order to test movement, player input is required. I was planning to do this using the "Press" function (as shown in documentation here, and as shown in an official unity tutorial here.) However, when I go to run the test, I am given the error that "The name 'Press' does not exist in the current context." Does anyone know why 'Press' is not being found.
Snippet of the test file is below. Also, the Unity.InputSystem assembly was already added to the assembly definition, so that is not the issue.
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
using UnityEngine.UI;
using UnityEngine.InputSystem;
public class MovementTest
{
Keyboard keyboard;
// A Test behaves as an ordinary method
[SetUp]
public void LevelUITestSetup()
{
SceneManager.LoadScene("TestPlayModeScene");
keyboard = InputSystem.AddDevice<Keyboard>();
Press(keyboard.rightArrowKey);
}
//a bunch of irrelevant tests here
}
If needed, the latest version of Unity Test Framework, and Unity Version 2022.3.18f1 are used.
According to docs, looks like your class should derive from InputTestFixture: