package:gcloud/service_scope.dart
私のアプリは、サービス スコープ ( )からオブジェクトにアクセスしていstorageService
ますss.register()
。
ここで、このスコープにアクセスし、サービス スコープに入れたいモック オブジェクトを使用する関数を単体テストしたいと考えています。
これを行う唯一の方法は、次のようにすべてのテストに登録することです。
var withServiceScope = (callback()) => ss.fork(() {
// Register all services here
return callback();
});
test('the description', () => withServiceScope(() async {
// Call my function that can now access the service scope
}));
または、setUp()
関数でそれを実行できるようにする方法があるので、テストごとにこの行を追加する必要はありませんか?