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

Testable and Immutability of ObjectBox

Open Peng-Qian opened this issue 4 years ago • 1 comments

Request

Make ObjectBox object is suitable to unit tests

Override Equality of Condition and implementations of Condition

Thus following code can work

       verify(() => mockBox.query(Entity_.id.equals(id))).called(1);

and use const constructor for ObjectBoxException

/// ObjectBox database exception.
class ObjectBoxException implements Exception {
  /// Exception message.
  final String message;

  /// Create a new exception.
  ObjectBoxException(this.message);  // <--- add const

  @override
  String toString() => 'ObjectBoxException: $message';
}

Peng-Qian avatar Aug 23 '21 03:08 Peng-Qian

This shoul be done, especially QueryBuilder contains private methods and cannot be mocked. So I can not write unit test for my repo classes because of QueryBuilder. This reduces coverage and blind spots. This issue opened 4 years ago.

bahadirarslan avatar Nov 14 '25 10:11 bahadirarslan