Search Issue Tracker
Won't Fix
Votes
0
Found in
2017.4.0f1
2018.3.0a1
2018.4.0f1
2019.1.0a1
2019.1.5f1
2019.2.0a1
2019.3.0a1
Issue ID
1160202
Regression
No
It is not possible to write Unit Tests in C# that Fakes modal dialogs
To reproduce:
1. Download attached “UnitTestFaking.zip" project and open in Unity
2. Open Test Runner
3. Press EditMode tab
4. Select "TestDialogWithCancel" Test and press "Run Selected" button
5. In the opened Dialog box press Cancel button
6. Observe that Test succeeded
7. Select "TestDialogWithCancel" Test and press "Run Selected" button
8. In the opened Dialog box press Save button
9. Observe that Test failed
Expected Result: Automated Unit-Test runs without the need for User Interaction
Actual Result: User Interaction is needed to complete Automated Unit-Test
Notes:
- This case is more like a Feature request
Reproduced on Unity 2017.4.0f1, 2017.4.29f1, 2018.3.14f1, 2018.4.2f1, 2019.1.6f1, 2019.2.0b5 and 2019.3.0a5
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
- ”Lighting data asset ‘LightingData’ is incompatible with the current Unity version…” warnings are thrown when saving Indoors (URP) and Outdoors (URP) Scenes as Scene Templates
- [iOS] The screen blinks when transitioning from custom to Unity splash screen
- [macOS] ”Ignoring depth surface load action as it is memoryless” warnings are thrown when taking Game View Snapshot
- UI Builder Inspector scrolls back up when changes on an expanded but not fully displayed Inspector tab are saved
- Group Node name text is way smaller in the renaming state than the actual display size
Resolution Note:
I am not sure why it is necessary to invoke the dialog.
If the intention of the test is to save the scene, then EditorSceneManager.SaveScene can be called, rather than EditorSceneManager.SaveModifiedScenesIfUserWantsTo. If the intention is to not save the scene, then the scene can just be closed without calling a save method