google_sign_in_mocks
0.4.2, released 2 months ago by wafrat.com
Mocks for Google Sign In to write unit tests for authentication.
What it does
Provides a mock implementation of Google Sign In for unit testing Dart and Flutter applications. It enables simulating successful sign-ins, user cancellations, and exceptions without requiring actual platform integrations.
AI-written summary of version 0.4.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are writing unit tests that involve Google Sign In.
- You want to test authentication flows and cancellation states locally.
Skip it when
- You are building production authentication features in your application.
Strengths
- Easy to set up and use in unit tests alongside firebase_auth_mocks.
- Allows simulation of canceled sign-ins and custom exceptions.
Weaknesses
- Limited only to mocking Google Sign In functionality for testing.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
Not documented
import 'package:google_sign_in_mocks/google_sign_in_mocks.dart';
import 'package:test/test.dart';
void main() {
late MockGoogleSignIn googleSignIn;
setUp(() {
googleSignIn = MockGoogleSignIn();
});
test('should return idToken when authenticating', () async {
final signInAccount = await googleSignIn.signIn();
final signInAuthentication = await signInAccount!.authentication;
expect(signInAuthentication, isNotNull);
});
}Alternatives
Packages that do the same job and could replace google_sign_in_mocks.
- firebase_storage_mocks
Mocks for Firebase Storage to write unit tests.
82Compare - firebase_database_mocks
Mock library to write unit tests for Firebase Realtime Database.
77Compare - mocktail_image_network
Mock Image.network in widget tests without real network calls
81Compare - build_test
Utilities for unit testing Dart build_runner builders in memory
78Compare
Works with
Packages commonly used together with google_sign_in_mocks: ones it builds on, ones built on it, and its own family.
- google_sign_ingoogle_sign_in_mocks depends on itOfficial Flutter plugin for authenticating users and requesting OAuth scopes via Google Sign-In.
- mock_exceptionsgoogle_sign_in_mocks depends on itAllows throwing exceptions on specified method calls in fakes
- fake_cloud_firestoreSame familyFake implementation of Cloud Firestore for unit testing.
- firebase_auth_mocksSame familyMocks for Firebase Auth to enable unit testing of authentication flows.