Search Unity

Question Unable to load DLL 'libc' when using [TestFixtureSource]

Discussion in 'Testing & Automation' started by CDF, Aug 18, 2021.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    I'm trying to build some tests using [TestFixtureSource], but the tests are failing with the error: Unable to load DLL 'libc'

    Code (CSharp):
    1.  
    2. FixtureTest (0.001s)
    3. ---
    4. An exception was thrown while loading the test.
    5. System.DllNotFoundException: Unable to load DLL 'libc'. Tried the load the following dynamic libraries:
    6.   at NUnit.Framework.Internal.OSPlatform.uname (System.IntPtr buf) [0x00000] in <00000000000000000000000000000000>:0
    7.   at NUnit.Framework.Internal.OSPlatform.CheckIfIsMacOSX (System.PlatformID platform) [0x00000] in <00000000000000000000000000000000>:0
    8.   at NUnit.Framework.Internal.OSPlatform+<>c.<.cctor>b__92_0 () [0x00000] in <00000000000000000000000000000000>:0
    9.   at System.Func`1[TResult].Invoke () [0x00000] in <00000000000000000000000000000000>:0
    10.   at System.Lazy`1[T].InitValue () [0x00000] in <00000000000000000000000000000000>:0
    11.   at System.Lazy`1[T].get_Value () [0x00000] in <00000000000000000000000000000000>:0
    12.   at NUnit.Framework.Internal.OSPlatform.get_CurrentPlatform () [0x00000] in <00000000000000000000000000000000>:0
    13.   at NUnit.Framework.Internal.PlatformHelper..ctor () [0x00000] in <00000000000000000000000000000000>:0
    14.   at NUnit.Framework.TestCaseAttribute+<BuildFrom>d__63.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    15.   at NUnit.Framework.Internal.Builders.DefaultTestCaseBuilder.BuildFrom (NUnit.Framework.Interfaces.IMethodInfo method, NUnit.Framework.Internal.Test parentSuite) [0x00000] in <00000000000000000000000000000000>:0
    16.   at NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.BuildTestCase (NUnit.Framework.Interfaces.IMethodInfo method, NUnit.Framework.Internal.TestSuite suite) [0x00000] in <00000000000000000000000000000000>:0
    17.   at NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.AddTestCasesToFixture (NUnit.Framework.Internal.TestFixture fixture) [0x00000] in <00000000000000000000000000000000>:0
    18.   at NUnit.Framework.Internal.Builders.NUnitTestFixtureBuilder.BuildFrom (NUnit.Framework.Interfaces.ITypeInfo typeInfo) [0x00000] in <00000000000000000000000000000000>:0
    19.   at NUnit.Framework.Internal.Builders.DefaultSuiteBuilder.BuildFrom (NUnit.Framework.Interfaces.ITypeInfo typeInfo) [0x00000] in <00000000000000000000000000000000>:0
    20.   at NUnit.Framework.Api.DefaultTestAssemblyBuilder.GetFixtures (System.Reflection.Assembly assembly, System.Collections.IList names) [0x00000] in <00000000000000000000000000000000>:0
    21.   at NUnit.Framework.Api.DefaultTestAssemblyBuilder.Build (System.Reflection.Assembly assembly, System.String assemblyPath, System.Collections.Generic.IDictionary`2[TKey,TValue] options) [0x00000] in <00000000000000000000000000000000>:0
    22.   at NUnit.Framework.Api.DefaultTestAssemblyBuilder.Build (System.Reflection.Assembly assembly, System.Collections.Generic.IDictionary`2[TKey,TValue] options) [0x00000] in <00000000000000000000000000000000>:0
    23.   at UnityEngine.TestTools.NUnitExtensions.UnityTestAssemblyBuilder+<BuildAsync>d__3.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    24.   at UnityEngine.TestTools.NUnitExtensions.UnityTestAssemblyBuilder.Build (System.Reflection.Assembly[] assemblies, UnityEngine.TestTools.TestPlatform[] testPlatforms, System.Collections.Generic.IDictionary`2[TKey,TValue] options) [0x00000] in <00000000000000000000000000000000>:0
    25.   at UnityEngine.TestRunner.NUnitExtensions.Runner.UnityTestAssemblyRunner.Load (System.Reflection.Assembly[] assemblies, UnityEngine.TestTools.TestPlatform testPlatform, System.Collections.Generic.IDictionary`2[TKey,TValue] settings) [0x00000] in <00000000000000000000000000000000>:0
    26.   at UnityEngine.TestTools.TestRunner.PlaymodeTestsController+<Run>d__16.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    27.   at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
    28.   at UnityEngine.MonoBehaviour.StartCoroutineManaged2 (System.Collections.IEnumerator enumerator) [0x00000] in <00000000000000000000000000000000>:0
    29.   at UnityEngine.MonoBehaviour.StartCoroutine (System.Collections.IEnumerator routine) [0x00000] in <00000000000000000000000000000000>:0
    30.   at UnityEngine.TestTools.TestRunner.PlaymodeTestsController+<Start>d__12.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
    31.   at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
    32. ---
    33. Test Started: FixtureTest
    34.  
    simple test code:
    Code (CSharp):
    1. using NUnit.Framework;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. namespace Tests.Fixture {
    7.  
    8.     [TestFixture]
    9.     [TestFixtureSource(typeof(FixtureTestData), "FixtureData")]
    10.     public class FixtureTest {
    11.  
    12.  
    13.         #region Fields
    14.  
    15.         private readonly string data;
    16.  
    17.         #endregion
    18.  
    19.         public FixtureTest(string data) {
    20.  
    21.             this.data = data;
    22.         }
    23.  
    24.         #region Unity Methods
    25.         #endregion
    26.  
    27.         #region Public Methods
    28.  
    29.         [TestCase("Name")]
    30.         [TestCase("Main Camera")]
    31.         [TestCase("Light")]
    32.         public void CompareName(string name) {
    33.  
    34.             Assert.That(data == name);
    35.         }
    36.  
    37.         #endregion
    38.  
    39.         public class FixtureTestData {
    40.  
    41.             public static IEnumerable FixtureData {
    42.  
    43.                 get {
    44.  
    45.                     yield return new TestFixtureData("Name");
    46.                     yield return new TestFixtureData("Main Camera");
    47.                     yield return new TestFixtureData("Light");
    48.                 }
    49.             }
    50.         }
    51.     }
    52. }
    The platform I'm targeting is Switch. Is [TestFixtureSource] not supported on Switch?