Skip to main content

Posts

Showing posts with the label forms

A month of Flutter: testing forms

Originally published on bendyworks.com . With the new  user registration form  in place, it's time to make sure the form is  tested  and will work as expected. There are basically five different states that need to be tested. Default state This is the view users will first arrive to and here I'm testing that all the components are present as expected. testWidgets ( 'Renders' , ( WidgetTester tester ) async { await tester . pumpWidget ( app ); expect ( find . text ( 'Register' ), findsOneWidget ); expect ( find . text ( 'I agree to the Terms of Services and Privacy Policy' ), findsOneWidget ); expect ( find . byType ( TextFormField ), findsNWidgets ( 2 )); expect ( find . byType ( OutlineButton ), findsOneWidget ); expect ( find . byType ( Checkbox ), findsOneWidget ); }); Submitted To succesfully submit the form, I require the user to provide a nickname and a full name. In the test those values wil...