【问题标题】:Testing Realm in PCL for Xamarin在 PCL 中为 Xamarin 测试领域
【发布时间】:2017-08-22 15:39:08
【问题描述】:
RealmConfiguration _configuration = new RealmConfiguration(Path.GetTempFileName());     
var realm = Realm.GetInstance(_configuration);

错误:

System.TypeInitializationException : The type initializer for 'Realms.Realm' threw an exception.
  ----> System.DllNotFoundException : realm-wrappers

如何为 PCL 中的集成测试初始化​​领域测试数据库?

【问题讨论】:

    标签: xamarin realm


    【解决方案1】:

    According to documentation,PCL 库只包含存根——这些方法不应该被调用。您应该在实际应用程序中运行测试。如果使用 NUnit,您可以使用 NUnitLite runner 创建一个非常简单的控制台运行器。确保在控制台应用程序中添加对 Realm 的引用。

    【讨论】:

    • 我目前正在使用 NUnit,是否可以使用集成测试运行器在 Visual Studio 中运行? ,这是我收到以下错误的时候: System.DllNotFoundException : realm-wrappers
    • @B.Afo using the integrated test runner?.. 不,您需要使用特定于平台的运行器。有适用于 Android/iOS 等的 xUnit/NUnit 平台运行器...
    • 查看github.com/realm/realm-dotnet/tree/master/Tests/Tests.NetCore 示例项目。因为测试设置使用共享项目,我们只传递typeof(Program).GetTypeInfo().Assembly 作为由AutoRun 运行的程序集,但如果您在PCL 程序集中有测试,您也应该传递这些程序集:new AutoRun(PCLAssembly1, PCLAssembly2,...)。尽管如此,正如@SushiHangover 所说,测试将由控制台应用程序执行,而不是由集成运行器执行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多