Skip to content
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

Testing using loggingService? #164

Open
dnfield opened this issue Jul 9, 2019 · 1 comment
Open

Testing using loggingService? #164

dnfield opened this issue Jul 9, 2019 · 1 comment

Comments

@dnfield
Copy link
Contributor

dnfield commented Jul 9, 2019

Is there a good way to mock or stub the loggingService when writing unit tests? Or perhaps overriding the service scope resolution?

Basically I'd like to test a method that ends up calling loggingService.xxx in some cases, and right now when I hit those branches I get output like the following:

Bad state: Not running inside a service scope zone.
package:gcloud/service_scope.dart 140:5                      lookup
package:appengine/src/logging.dart 67:31                     loggingService
package:cocoon_service/github.dart 21:5                      getPullRequest
===== asynchronous gap ===========================
dart:async                                                   _AsyncAwaitCompleter.completeError
package:cocoon_service/github.dart                           getPullRequest
===== asynchronous gap ===========================
dart:async                                                   _asyncThenWrapperHelper
package:cocoon_service/request_handlers/github_webhook.dart  githubWebhookPullRequest
test/request_handlers/github_webhook_test.dart 77:13         main.<fn>.<fn>
No matching calls (actually, no calls at all).
(If you called `verify(...).called(0);`, please instead use `verifyNever(...);`.)
package:test_api                                      fail
package:mockito/src/mock.dart 641:7                   _VerifyCall._checkWith
package:mockito/src/mock.dart 834:18                  _makeVerify.<fn>
test/request_handlers/github_webhook_test.dart 39:13  main.<fn>.<fn>
✖ githubWebhookPullRequest Rejects non-json
Exited (1)

@jonasfj
Copy link
Member

jonasfj commented Jul 11, 2019

No, but if you're using https://pub.dev/packages/logging then you can avoid setting up AppEngine services when running tests.

Just call useLoggingPackageAdaptor when using services and logs will get picked up by the logging service.

@devoncarew devoncarew transferred this issue from dart-archive/appengine Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants