Closed SankethBK closed 10 months ago
I'm done with my previous issue. Please assign this to me.
Sure
@SankethBK could you point me to the directory where i can find all crud operations?
@PratyushChauhan In integration testing we simulate the actual actions like clicking the button, writing something in textbox, etc. Checkout this video for more info.
While testing we need to avoid network calls, so when the app opens you can simulate following steps for a test
You can come up with multiple scenarios like this for updating, deleting notes as well
Got it thanks
After following the tutorial I made a simple unit test for guest login
import 'package:dairy_app/app/view/app.dart';
import 'package:dairy_app/core/pages/home_page.dart';
import 'package:dairy_app/features/auth/presentation/pages/auth_page.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
Future<void> main() async{
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('Guest login test, click on sign up button to move reveal guest login button'
'click the guest login button to enter HomePage', (WidgetTester tester) async {
await tester.pumpWidget(App());
await tester.pumpAndSettle();
await tester.tap(find.text('Sign up'));
await tester.pumpAndSettle();
await tester.tap(find.text('Continue as guest'));
await tester.pumpAndSettle();
expect(find.byType(HomePage), findsOneWidget);
expect(find.byType(AuthPage), findsNothing);
});
}
Upon running flutter test path/to/guestlogintest.dart
i got an unexpected error.
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following StateError was thrown building _InheritedProviderScope<ThemeCubit?>(value: <not yet
loaded>):
Bad state: GetIt: Object/factory with type AuthSessionBloc is not registered inside GetIt.
(Did you accidentally do GetIt sl=GetIt.instance(); instead of GetIt sl=GetIt.instance;
Did you forget to register it?)
The relevant error-causing widget was:
_InheritedProviderScope<ThemeCubit?>
_InheritedProviderScope:file:///C:/Users/ciphe/AppData/Local/Pub/Cache/hosted/pub.dev/provider-6.0.5/lib/src/inherited_provider.dart:161:12
Full stack trace can be found here.
Is it a state management related exception?
@PratyushChauhan can you share the PR, i will try it out locally. It appears like get_it
ins't initialized, because of which its not able to find dependencies.
PR initiated
We can add integration tests using
integration_test
package. Refer this docs for more details.We can add integration tests around CRUD operations for notes. Initially we can use
Continue as guest
as option in signup page, create a new note with title and body, save it and check it is displayed in home page.We can similarly check by updating an existing note to check if updation is working, and delete a note and check if it is removed from home page