Flutter ObjectBox - 如何进行单元测试?
Flutter ObjectBox - How to unittest?
我正在使用 objectBox 作为数据库构建我的新 Flutter 应用程序。
如何在 Android Studio 中编写单元测试?
当我编写包含 objectBox 的单元测试时,在 运行 测试中我收到以下错误消息:
Failed to load "C:\Dev\flutter_rebuild\test\db_model_test.dart": Invalid argument(s): Failed to load dynamic library 'lib/objectbox.dll': 126
我发现这个:
https://opensourcelibs.com/lib/objectbox-dart
它显示了如何下载包含“objectbox.dll”到 Windows,以便测试可以 运行 在 Android Studio 中。
Dart standalone programs:
- Install the packages pub get
- Install objectbox-c system-wide:
macOS/Linux: execute the following command (answer Y when it asks about installing to /usr/lib)
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
macOS: if dart later complains that it cannot find the libobjectbox.dylib you probably have to unsign the dart binary (source: dart issue):
sudo codesign --remove-signature $(which dart)
Windows: use "Git Bash" or similar to execute the following command
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
Then copy the downloaded lib/objectbox.dll to C:\Windows\System32\ (requires admin privileges).
ObjectBox generates code binding code for classes you want stored based using build_runner. After you've defined your persisted entities (see below), run pub run build_runner build
or flutter pub run build_runner build
.
我正在使用 objectBox 作为数据库构建我的新 Flutter 应用程序。 如何在 Android Studio 中编写单元测试?
当我编写包含 objectBox 的单元测试时,在 运行 测试中我收到以下错误消息:
Failed to load "C:\Dev\flutter_rebuild\test\db_model_test.dart": Invalid argument(s): Failed to load dynamic library 'lib/objectbox.dll': 126
我发现这个: https://opensourcelibs.com/lib/objectbox-dart 它显示了如何下载包含“objectbox.dll”到 Windows,以便测试可以 运行 在 Android Studio 中。
Dart standalone programs:
- Install the packages pub get
- Install objectbox-c system-wide:
macOS/Linux: execute the following command (answer Y when it asks about installing to /usr/lib)
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
macOS: if dart later complains that it cannot find the libobjectbox.dylib you probably have to unsign the dart binary (source: dart issue):
sudo codesign --remove-signature $(which dart)
Windows: use "Git Bash" or similar to execute the following command
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
Then copy the downloaded lib/objectbox.dll to C:\Windows\System32\ (requires admin privileges).
ObjectBox generates code binding code for classes you want stored based using build_runner. After you've defined your persisted entities (see below), run
pub run build_runner build
orflutter pub run build_runner build
.