Search Issue Tracker
By Design
By Design in 2.0.X
Votes
0
Found in [Package]
2.0.0-preview
Issue ID
RIDER-39
Regression
Yes
Unit tests fail on System.TypeInitializationException when using the Standalone NUnit Launcher in JetBrains Rider
How to reproduce:
1. Open the “DllTest_UnityMoq2021.3.29f1.zip“ project
2. Go to Preferences->External Tools->External Script Editor and set it to Rider 2022.3.3
3. Open JetBrains Rider and open the project
4. Open the Unit Tests tab (Alt + 8)
5. Select the Standalone NUnit Launcher option.
6. Run the Unit Tests
Expected result: Tests are successful
Actual result: Tests failed
Reproducible with: 2.0.0-pre.2 (2021.3.32f1, 2023.2.0b16, 2023.3.0a12)
Not reproducible with: 1.0.0 (2022.3.12f1, 2023.1.19f1)
Reproducible on: Windows 10, Windows 11
Not reproducible on: No other environment tested
Error: System.TypeInitializationException : The type initializer for 'Moq.Async.AwaitableFactory' threw an exception.
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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
Resolution Note:
The solution was to set up the nuget.castle-core package. In this case, nuget.moq was setup correctly, so in the included test project, Tests.asmdef looks like this:
{
...
"precompiledReferences": [
"Moq.dll",
"nunit.framework.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
"System.Threading.Tasks.Extensions.dll"
],
...
}
But nuget.moq depends on nuget.castle-core, which also needs to be set up (https://docs.unity3d.com/Packages/nuget.castle-core@2.0/manual/index.html#setup).
So the Tests.asmdef should look like:
{
...
"precompiledReferences": [
"Castle.Core.dll",
"System.Diagnostics.EventLog.dll",
"Moq.dll",
"nunit.framework.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
"System.Threading.Tasks.Extensions.dll"
],
...
}
With those changes (already documented), there should no longer be a problem.
Resolution Note (2.0.X):
The solution was to set up the nuget.castle-core package. In this case, nuget.moq was setup correctly, so in the included test project, Tests.asmdef looks like this:
{
...
"precompiledReferences": [
"Moq.dll",
"nunit.framework.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
"System.Threading.Tasks.Extensions.dll"
],
...
}
But nuget.moq depends on nuget.castle-core, which also needs to be set up (https://docs.unity3d.com/Packages/nuget.castle-core@2.0/manual/index.html#setup).
So the Tests.asmdef should look like:
{
...
"precompiledReferences": [
"Castle.Core.dll",
"System.Diagnostics.EventLog.dll",
"Moq.dll",
"nunit.framework.dll",
"System.Runtime.CompilerServices.Unsafe.dll",
"System.Threading.Tasks.Extensions.dll"
],
...
}
With those changes (already documented), there should no longer be a problem.