New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with unit testing using Realm: Failed to Load Dynamic Library Error #1619
Comments
➤ PM Bot commented: Jira ticket: RDART-999 |
@Taco55 Flutter test are (unlike driver or integration tests) run on your local host. Please run:
in the root of your project, similar to what you would do with a non-flutter project. This should create a binary folder in your project root, in which you will find the mentioned lib:
In your tests you might want to use import 'package:flutter_test/flutter_test.dart';
import 'package:realm/realm.dart';
import 'package:realm_unittest/main.dart';
void main() {
test('Test with Realm', () {
final realm = Realm(Configuration.inMemory([Counter.schema]));
realm.write(() {
realm.add(Counter(0));
});
expect(realm.all<Counter>().first.value, 0);
});
} Now it should work:
|
@Taco55 .. so the above is how it should work, but it seems we have an issue in 2.0.0. WORKAROUNDBefore running dependencies:
# disable flutter dep
# flutter:
# sdk: flutter
realm: ^2.0.0
realm_dart: ^2.0.0 # add explicit dep on realm_dart run:
Revert the changes to pubspec.yaml |
Yes, that did the trick! Thanks for your help. |
When I do
It want me to specified target OS, which it didn't before 2.0.0
So I specified the target OS like below
But it install to the unexpected path
After I copied |
@nielsenko should we reopen this until we have a proper fix? |
@triplehman3563 The reason (and the reason why the work-around works) is that in 2.0.0 we deduce the project type (flutter vs. dart) from the Copying the lib in place like you did will also work. |
I copied the .so manually in my github-action, but it still isn't working. Would this be part of the same issue?
Compared to the error before I copied the *.so, which matches the OPs error:
|
any fix to this @nirinchev @nielsenko would be appreciated |
Sorry, the fix did not make it into 2.1.0, 2.2.0, or 2.2.1. The work-around still stand, and I will try to get the fix merged before next release. |
What happened?
I'm encountering persistent errors when attempting to run unit tests. Following an upgrade to Realm 2.0.0, the tests fail to execute, consistently yielding the following error:
This issue seems to recur with every Realm upgrade, but previously, I managed to resolve it. Could you please provide guidance on how to address this error? Additionally, I would greatly appreciate any advice on best practices for upgrading Realm in a manner that does not affect unit tests (increasing the version in pubspec.yaml usually breaks unit tests).
Repro steps
flutter test
Version
3.3.3/3.19.5
What Atlas Services are you using?
Local Database only
What type of application is this?
Flutter Application
Client OS and version
macOS 14.2.1
Code snippets
void main() {
late Realm realm;
test("Open a local realm", () {
realm = Realm(Configuration.local([Car.schema]));
expect(realm.isClosed, isFalse);
});
tearDown(() {
realm.close();
});
}
Stacktrace of the exception/crash you're getting
No response
Relevant log output
The text was updated successfully, but these errors were encountered: