objectbox-dart icon indicating copy to clipboard operation
objectbox-dart copied to clipboard

Unable to run unittests with objectbox

Open centy opened this issue 1 year ago • 5 comments
trafficstars

Is there an existing issue?

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

centy avatar Mar 09 '24 10:03 centy

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

techouse avatar Mar 09 '24 18:03 techouse

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

centy avatar Mar 09 '24 19:03 centy

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

techouse avatar Mar 09 '24 19:03 techouse

Sounds like workaround

centy avatar Mar 09 '24 19:03 centy

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.

greenrobot-team avatar Mar 11 '24 07:03 greenrobot-team

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.

github-actions[bot] avatar Apr 02 '24 01:04 github-actions[bot]