Search Issue Tracker
In Progress
Votes
0
Found in [Package]
1.14.0
Issue ID
ISXB-1509
Regression
No
ArgumentOutOfRangeException thrown when defining device in [OneTimeSetUp] and using [OneTimeTearDown] to remove it
How to reproduce:
1. Open the project "IN-97542_Keyboard"
2. Open Windows → General → Test Runner
3. Click on "PlayMode"
4. Double click the "Ch 18 - Unity testing"
5. Observe the Console
Expected result: Fails gracefully, with a more defined error message
Actual result: ArgumentOutOfRangeException thrown
Reproducible with: 1.5.0 (2023.2.0a1) 1.14.0 (2023.2.0a1, 2022.3.61f1, 6000.0.46f1, 6000.1.0b14, 6000.2.0a8)
Reproducible on: Windows 11
Not reproducible on: No other environments tested
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- var VisionOSEDRHeadromm has a comma instead of a dot when building with Metal Rendering App Mode and local OS localization is set to German
- IAP Catalog remove product “x” and add product “+” buttons are not consistent with other remove and add buttons in the Editor
- Performance issues in Play Mode when quickly hovering the mouse cursor over Hierarchy GameObjects
- Frame Debugger displays incorrect output when FidelityFX Super Resolution or Spatial-Temporal Upscaler is used with Temporal Anti-aliasing or Subpixel Morphological Anti-aliasing
- The layout system is failing to correctly calculate or apply the height of the Japanese fallback font when the primary English font's metrics are used
Resolution Note:
When using the InputTestFixture you need to use [SetUp] and [TearDown]. [OneTimeSetup] & [OneTimeTeardown] have different timing and won't work well with the InputTestFixture's lifecycle.
This is due to how the InputTestFixture mocks user input data and it's load / restore mechanism. Old data was restored in your repo project's case causing issues.
We have added documentation around this for an upcoming release to avoid confusion.
Here is also a minimal working test for this case that had the same scene setup used in the repo project. Copying this Setup / Teardown code should fix the issue for you.
Swapping between [OneTimeSetup] & [OneTimeTearDown] vs [SetUp] & [TearDown] with the same code should also reproduce / fix the error without the need for the workaround you provided also.
using System.Collections;
using NUnit.Framework;
using UnityEditor.SceneManagement;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
namespace Tests.InputSystem
{
public class SceneLoadingTests : InputTestFixture
{
private const string TestScenePath = "Assets/Tests/InputSystem/Assets/AutoSwitchBoolTestScene.unity";
private Scene m_Scene;
[SetUp]
public void SetUpTest()
{
m_Scene = EditorSceneManager.LoadSceneInPlayMode(TestScenePath, new LoadSceneParameters(LoadSceneMode.Additive));
}
[TearDown]
public void TearDown()
{
SceneManager.UnloadScene(m_Scene);
}
[UnityTest]
[Category("SceneLoading")]
public IEnumerator Users_CanLoadASceneWithPlayerInputAutoSwitchFlagSetToTrue_InTestsWithInputTestFixture()
{
yield return null;
}
}
}