Search Issue Tracker
Fixed
Fixed in 1.1.10
Votes
0
Found in [Package]
1.1.9
Issue ID
DSTR-10
Regression
No
[TestRunner] "EditMode test can only yield null" error is thrown when two or more yield returns are used in one test
Further investigation showed that it is not the nested-IEnumerator situation that doesn't work, but the nested-Ienumerator+AsyncOperation that is not handled as an AsyncOperation in the right place/time. The solution introduced in the PR, works for this case but introduces thread-related problems in other cases. Example AsyncProgressBar.ProgresTests.SynchronousProtectionInMultithreaded()
How to reproduce:
1. Open the attached "case_1171956" project
2. Go to Window -> General -> Test Runner
3. Run all tests
Expected result: Both tests will pass
Actual result: Only test with one yield return passes
Reproducible with: 2017.4.31f1, 2018.4.5f1, 2019.1.13f1, 2019.2.0f1, 2019.3.0a11
Full error message:
EditMode test can only yield null
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
Additional notes:
1. This issue occurs only in tests. Calling two or more yield returns in MonoBehavior script works as expected
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
- URP SoftShadowsHigh not initialized
- Crash on Material::RemoveUnusedProperties() when removing unused properties from a broken Material Component
- Sprite Atlas Sample variant scene sprites are blurry
- Disabled Shadow Variants are removed from the Player when 'Strip Unused Variants" is disabled and no URP Asset with Disabled Shadows is in Build
- Graphics.RenderMeshIndirect does not issue multi-draw rendering commands when using a graphics API capable of multi-draw commands
barbarbarian
Mar 14, 2023 01:38
Multiple yield returns in a single [UnitTest] works for me. However, I did get this error when I was trying to run my async call with a yield return. Make sure you are only using yield return with a method of type IEnumerator or if you are trying to running a method that is async but not IEnumerator (so like a task), trying using AsIEnumerator() - that is: myAsyncTaskMethod.AsIEnumerator().