objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
918 stars 116 forks source link

Unable to run unittests with objectbox #611

Closed centy closed 1 month ago

centy commented 1 month ago

Is there an existing issue?

Build info

Steps to reproduce

void main() { test('test', () async { final store = await openStore(directory: 'test.db'); }); }

Expected behavior

Running test is expected

Actual behavior

Invalid argument(s): Failed to load dynamic library 'objectbox.dll': The specified module could not be found. (error code: 126) dart:ffi new DynamicLibrary.open package:objectbox/src/native/bindings/bindings.dart 84:29 _tryObjectBoxLibFile package:objectbox/src/native/bindings/bindings.dart 123:12 loadObjectBoxLib package:objectbox/src/native/bindings/bindings.dart 144:22 C package:objectbox/src/native/bindings/bindings.dart C package:objectbox/src/native/model.dart 19:31 new Model package:objectbox/src/native/store.dart 225:21 new Store package:pixyfy_color_by_number/objectbox/objectbox.g.dart 131:5 openStore

techouse commented 1 month ago

Upgrade to v2.5.0 and use file-less in-memory databases for your tests.

centy commented 1 month ago

I have 2.5.0. Same error. Invalid argument(s): Failed to load dynamic library 'objectbox.dll': The specified module could not be found.

techouse commented 1 month ago

https://stackoverflow.com/questions/69631115/flutter-objectbox-unit-testing-failed-to-load-dynamic-library-lib-objectbox-d

centy commented 1 month ago

Sounds like workaround

greenrobot-team commented 1 month ago

It's correct. For unit tests you need to download the native library for your machine manually. I made the note on https://docs.objectbox.io/getting-started about this more prominent.

Edit: we welcome any suggestions on how to automate this.

github-actions[bot] commented 1 month ago

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.