objectbox-dart
objectbox-dart copied to clipboard
Unable to run unittests with objectbox
Is there an existing issue?
- [X] I have searched existing issues
Build info
- objectbox version: ^2.4.0
- Flutter 3.19.1 • channel stable • https://github.com/flutter/flutter.git
- Framework • revision abb292a07e (3 weeks ago) • 2024-02-20 14:35:05 -0800
- Engine • revision 04817c99c9
- Tools • Dart 3.3.0 • DevTools 2.31.1
- Build OS: Windows 10
- Deployment OS or device: [Android 14]
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
Upgrade to v2.5.0 and use file-less in-memory databases for your tests.
I have 2.5.0. Same error. Invalid argument(s): Failed to load dynamic library 'objectbox.dll': The specified module could not be found.
https://stackoverflow.com/questions/69631115/flutter-objectbox-unit-testing-failed-to-load-dynamic-library-lib-objectbox-d
Sounds like workaround
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.
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.