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

Support unit tests with realm in Flutter projects

Open nielsenko opened this issue 2 years ago • 2 comments

  • Avoid opening plugin lib when running flutter test
  • Allow running dart run realm install in flutter project to install realm lib for unit tests
  • Use new --flavor flag

Fixes #791, fixes #870

nielsenko avatar Oct 03 '22 14:10 nielsenko

This PR allows you to run:

dart run realm install

or

fluter pub run realm install

in a flutter project to install the dynamic lib needed to run unit tests with dart test or flutter test correctly.

nielsenko avatar Oct 03 '22 15:10 nielsenko

Pull Request Test Coverage Report for Build 3910871991

  • 0 of 24 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.173%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/src/native/realm_core.dart 0 24 0.0%
<!-- Total: 0 24
Totals Coverage Status
Change from base Build 3891760475: 0%
Covered Lines: 2825
Relevant Lines: 3168

💛 - Coveralls

coveralls avatar Oct 09 '22 13:10 coveralls

Is there any simple steps that I can try this on my machine?

You can make a flutter project with tests that use realm. When running flutter test you will get a dlopen error. Then run flutter pub run realm install, which will download the desktop lib, and last re-run flutter test. Second time around it should work.. or at least it should load the lib correctly 😄

nielsenko avatar Nov 10 '22 09:11 nielsenko

@nielsenko Is it possible to have commands like these: dart run realm_dart install and flutter pub run realm install instead of dart realm install --flavor dart or flutter pub run realm install --flavor dart. It's quite confusing to select flavor dart when you are installing flutter. It will be better if we can ship this fix without any changes at the existing commands, just allowing the new command flutter pub run realm install to be run, because we don't have a way to test these commands before to release.

desistefanova avatar Nov 17 '22 09:11 desistefanova

@nielsenko Is it possible to have commands like these: dart run realm_dart install and flutter pub run realm install instead of dart realm install --flavor dart or flutter pub run realm install --flavor dart. It's quite confusing to select flavor dart when you are installing flutter. It will be better if we can ship this fix without any changes at the existing commands, just allowing the new command flutter pub run realm install to be run, because we don't have a way to test these commands before to release.

As a user you don't have to add the flavor flag. Both of the commands you mention should suffice, as the default does the right thing.

nielsenko avatar Nov 17 '22 11:11 nielsenko