An in-depth analysis of testing widgets in Flutter. Part I: testWidgets () and TestVariant

The translation was prepared as part of the online course " Flutter Mobile Developer ".



We invite everyone to a free two-day intensive "Creating a Flutter App for Web, iOS and Android" . Learn more and register here.






,  β€” . , , , , . , , .





, - , , , .





.





 β€” ?





Flutter- , . , . - . - , , :





?





, , - , , . , , , Β« Β» .





, , , : , , . .





, «»  β€” , , - . , .





lib test.





 





Flutter, , .





:





, :





  1. main()



    , , .





  2. testWidgets()



    , , .





  3. testWidgets()



    .





, , . , .





testWidgets()

testWidgets



 β€” ?





, .





,  , , , , .  β€” ,  skip.





, . Β―\_(ツ)_/Β―





-

, - .





, , : initialTimeout



 β€” -, , ,    timeout



.





- :





-, timeout



, .





: setUp() tearDown()

testWidgets()



, Flutter β€” .





:





setUpAll()



 tearDownAll()



 β€” . setUp()



 tearDown()



. .





, .





testWidgets():

, , .





, : , , . (enum):





, :





setUp()



 tearDown()



, , ,  β€” get values



.





WidgetColor



:





WidgetColor



. variant



:





WidgetColor



:





, , . .






"Flutter Mobile Developer".





Β« Flutter Web, iOS AndroidΒ»








All Articles