davidmartos96 / sqflite_sqlcipher

SQLite flutter plugin
BSD 2-Clause "Simplified" License
96 stars 41 forks source link

Can't do unit test [ MissingPluginException(No implementation found for method openDatabase on channel com.davidmartos96.sqflite_sqlcipher)] #68

Closed tarekmabdallah91 closed 1 year ago

tarekmabdallah91 commented 1 year ago

Hello,

Before implementing sqflite_sqlcipher the unit test for sqflite was working good, but now I faced this exception
MissingPluginException(No implementation found for method openDatabase on channel com.davidmartos96.sqflite_sqlcipher)

Mocking Scenario working well, but I want unit test also.

openning db code which throw this exception :

Future<Database> database({
    String? testingPath,
    String? testingPassword,
  }) async =>
      openDatabase(
        testingPath ?? path.join(await getDatabasesPath(), DB_NAME),
        password: testingPassword ?? await SecuredDataStorage().getDbPassword(),
        onCreate: (db, version) => db.execute(setupDbQuery),
        version: 1,
      );

Thanks

davidmartos96 commented 1 year ago

You can use sqflite_sqlcipher with pure Dart, but you need to configure the environment. That means that you need to have the SQLCipher binaries available in your machine. Doing sqlcipher in your terminal should give you something similar to SQLite version 3.39.2 2022-07-21 15:24:47 (SQLCipher 4.5.2 community)

In the following snippet there is an example of using this library in pure Dart. You can adapt it for your unit tests. https://github.com/davidmartos96/sqflite_sqlcipher/issues/28#issuecomment-733636725