Following Flutter's unit-testing guide, you can adapt it to your project. Say you have some classes depending on ObjectBox in the lib
folder. In that case, just create your test cases for package:test
as you normally would, and provide a locally opened database: just import openStore
from your lib/objectbox.g.dart
(or wherever you have the generated code. The database will be saved in the current directory (in the objectbox
subdirectory), unless specified otherwise. It is good practice to delete this directory in the tearDown
function of the test group.
Considering the class you've posted in the question - it must get the store
from somewhere, right? So for example you'd give the store opened in the test folder as a constructor argument.