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
- [Dragon Crashers] Build fails in U6
- [Dragon Crashers] 4 Shader error messages on import
- [Dragon Crashers] Readme text is white on light grey
- Cursor stays in front of the first character when entering text in the TextMeshPro field
- Searching in Hierarchy causes unwanted component calls
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