Slide 1

Slide 1 text

࣌ాཧ(.01FQBCP *OD %BSU.FFUVQ0TBLB 'MVUUFS1SPWJEFSͰ ΢ΟδΣοτͷςετΛॻ͘

Slide 2

Slide 2 text

ϞόΠϧ8FCΞϓϦέʔγϣϯΤϯδχΞ ࣌ాཧ!PTBNUJNJ[FS 46;63*ࣄۀ෦ϓϩμΫτνʔϜ IUUQTPTBNUJNJ[FSIBUFOBCMPHDPN

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

ΦϦδφϧάοζ͕࡞ΕΔɺചΕΔɺങ͑Δɻ ը૾Λ1ຕΞοϓ ͢Δ͚ͩ ࣗಈతʹ঎඼͕ Ͱ͖·͢ ࣗ෼Ͱ΋ങ͑Δ͠ ചΔ͜ͱ΋Ͱ͖·͢

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

͸͡Ίʹ wࢿྉ͸ޙ΄ͲΠϯλʔωοτ্Ͱެ։͠·͢ wIUUQTTQFBLFSEFDLDPNPTBNUJNJ[FS

Slide 8

Slide 8 text

ࠓ೔࿩͢͜ͱ w'MVUUFSͷ8JEHFU5FTU w1SPWJEFSʹґଘͨ͠΢ΟδΣοτͷ8JEHFU5FTUΛॻ͘ w·ͱΊ

Slide 9

Slide 9 text

8JEHFU5FTU

Slide 10

Slide 10 text

΢ΟδΣοτʹର͢Δςετ

Slide 11

Slide 11 text

'MVUUFSʹ͓͚Δςετ w6OJU5FTU୯Ұͷϝιου΍Ϋϥεʹର͢Δςετ w*OUFHSBUJPO5FTUΞϓϦશମʹର͢Δςετ w8JEHFU5FTU୯Ұͷ΢ΟδΣοτʹର͢Δςετ

Slide 12

Slide 12 text

'MVUUFSʹ͓͚Δςετ w6OJU5FTU୯Ұͷϝιου΍Ϋϥεʹର͢Δςετ w*OUFHSBUJPO5FTUΞϓϦશମʹର͢Δςετ w8JEHFU5FTU୯Ұͷ΢ΟδΣοτʹର͢Δςετ

Slide 13

Slide 13 text

΢ΟδΣοτͷԿΛ ςετ͢Δʁ

Slide 14

Slide 14 text

΢ΟδΣοτͷ ݟͨ໨ͱڍಈ

Slide 15

Slide 15 text

8JEHFU5FTU͕Χόʔ͢Δ΋ͷ w΢ΟδΣοτ͸એݴతʹهड़ ˠঢ়ଶΛ༩͑ͨͱ͖ɺ૝ఆͨ͠ݟͨ໨ʹͳΔ͔ʁ wϢʔβʔͷೖྗΠϕϯτͳͲΛड͚ͯԿ͔Λ͢Δ΢ΟδΣοτ΋͋Δ ˠΠϕϯτ͕ൃՐͨ͠ͱ͖ɺ૝ఆͨ͠ڍಈΛ͢Δ͔ʁ

Slide 16

Slide 16 text

8JEHFU5FTUΛॻ͍ͯΈΔ void main() { testWidgets('MyWidget has a title and message', (WidgetTester tester) async { // ςετͷ४උ await tester.pumpWidget(MyWidget(title: 'T', message: 'M')); // ΢ΟδΣοτͷ୳ࡧ final titleFinder = find.text('T'); final messageFinder = find.text('M'); // ϚονϟͰ΢ΟδΣοτΛݕূ expect(titleFinder, findsOneWidget); expect(messageFinder, findsOneWidget); }); } ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 17

Slide 17 text

8JEHFU5FTUΛॻ͍ͯΈΔ void main() { testWidgets('MyWidget has a title and message', (WidgetTester tester) async { // ςετͷ४උ await tester.pumpWidget(MyWidget(title: 'T', message: 'M')); // ΢ΟδΣοτͷ୳ࡧ final titleFinder = find.text('T'); final messageFinder = find.text('M'); // ϚονϟͰ΢ΟδΣοτΛݕূ expect(titleFinder, findsOneWidget); expect(messageFinder, findsOneWidget); }); } ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 18

Slide 18 text

8JEHFU5FTUΛॻ͍ͯΈΔ void main() { testWidgets('MyWidget has a title and message', (WidgetTester tester) async { // ςετͷ४උ await tester.pumpWidget(MyWidget(title: 'T', message: 'M')); // ΢ΟδΣοτͷ୳ࡧ final titleFinder = find.text('T'); final messageFinder = find.text('M'); // ϚονϟͰ΢ΟδΣοτΛݕূ expect(titleFinder, findsOneWidget); expect(messageFinder, findsOneWidget); }); } ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 19

Slide 19 text

8JEHFU5FTUΛॻ͍ͯΈΔ void main() { testWidgets('MyWidget has a title and message', (WidgetTester tester) async { // ςετͷ४උ await tester.pumpWidget(MyWidget(title: 'T', message: 'M')); // ΢ΟδΣοτͷ୳ࡧ final titleFinder = find.text('T'); final messageFinder = find.text('M'); // ϚονϟͰ΢ΟδΣοτΛݕূ expect(titleFinder, findsOneWidget); expect(messageFinder, findsOneWidget); }); } ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 20

Slide 20 text

8JEHFU5FTUΛॻ͍ͯΈΔ void main() { testWidgets('Add and remove a todo', (WidgetTester tester) async { await tester.pumpWidget(TodoList()); // WidgetTesterܦ༝Ͱ΢ΟδΣοτΛૢ࡞ await tester.enterText(find.byType(TextField), 'hi'); await tester.tap(find.byType(FloatingActionButton)); // ΢ΟδΣοτΛϦϏϧυ await tester.pump(); expect(find.text('hi'), findsOneWidget); await tester.drag(find.byType(Dismissible), Offset(500.0, 0.0)); await tester.pumpAndSettle(); expect(find.text('hi'), findsNothing); }); } ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 21

Slide 21 text

8JEHFU5FTUΛॻ͍ͯΈΔ void main() { testWidgets('Add and remove a todo', (WidgetTester tester) async { await tester.pumpWidget(TodoList()); // WidgetTesterܦ༝Ͱ΢ΟδΣοτΛૢ࡞ await tester.enterText(find.byType(TextField), 'hi'); await tester.tap(find.byType(FloatingActionButton)); // ΢ΟδΣοτΛϦϏϧυ await tester.pump(); expect(find.text('hi'), findsOneWidget); await tester.drag(find.byType(Dismissible), Offset(500.0, 0.0)); await tester.pumpAndSettle(); expect(find.text('hi'), findsNothing); }); } ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 22

Slide 22 text

8JEHFU5FTUΛॻ͍ͯΈΔ void main() { testWidgets('Add and remove a todo', (WidgetTester tester) async { await tester.pumpWidget(TodoList()); // WidgetTesterܦ༝Ͱ΢ΟδΣοτΛૢ࡞ await tester.enterText(find.byType(TextField), 'hi'); await tester.tap(find.byType(FloatingActionButton)); // ΢ΟδΣοτΛϦϏϧυ await tester.pump(); expect(find.text('hi'), findsOneWidget); await tester.drag(find.byType(Dismissible), Offset(500.0, 0.0)); await tester.pumpAndSettle(); expect(find.text('hi'), findsNothing); }); } ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 23

Slide 23 text

8JEHFU5FTUͷ࣮ߦ $ flutter test 00:05 +1: All tests passed! ࢀߟIUUQTqVUUFSEFWEPDTDPPLCPPLUFTUJOHXJEHFUJOUSPEVDUJPO

Slide 24

Slide 24 text

8JEHFU5FTU wݕূ͍ͨ͠΢ΟδΣοτΛ5FTUFSʹ౉͢ wίʔυʹΑͬͯ΢ΟδΣοτΛૢ࡞ͯ͠ݕূ wཁૉ͕ଘࡏ͢Δ͔ wΠϕϯτൃՐ࣌ʹ૝ఆͨ͠ڍಈʹͳΔ͔

Slide 25

Slide 25 text

8JEHFU5FTUͷࠔΓͲ͜Ζ w6OJU5FTUͱൺֱ͢Δͱɺมߋʹऑ͍ w6*͸ͦ΋ͦ΋มߋ͞Ε΍͍͢ wςετ͸ͳΔ΂͘$*Ͱࣗಈ࣮ߦ͍ͤͨ͞ w͋·Γڽͬͨ8JEHFU5FTUΛॻ͖͗͢Δͱɺςετͷमਖ਼ʹ௥ΘΕΔ

Slide 26

Slide 26 text

1SPWJEFSʹґଘͨ͠ ΢ΟδΣοτͷςετ

Slide 27

Slide 27 text

1SPWJEFSʹґଘͨ͠΢ΟδΣοτͷςετ w1SPWJEFS w'MVUUFSͰͷঢ়ଶ؅ཧΛ͠΍͘͢͢Δύοέʔδ wґଘ͍ͯ͠Δ΢ΟδΣοτͷ8JEHFU5FTUʹ͸޻෉͕ඞཁ w͔͠͠ɺϝϦοτ΋͋Δ

Slide 28

Slide 28 text

αϯϓϧΞϓϦ

Slide 29

Slide 29 text

ˠ

Slide 30

Slide 30 text

αϯϓϧΞϓϦ wϝʔϧΞϓϦ wΞϓϦΛىಈ͢Δͱ࠷৽ͷϝʔϧΛऔಘͯ͠දࣔ wϦετΛλοϓ͢Δͱϝʔϧͷৄࡉը໘ʹϓογϡભҠ

Slide 31

Slide 31 text

αϯϓϧΞϓϦ .BUFSJBM"QQ )PNF 4DB⒎PME .BJM-JTU -JTU5JMF 1SPWJEFS -JTU5JMF -JTU5JMF

Slide 32

Slide 32 text

αϯϓϧΞϓϦ .BUFSJBM"QQ )PNF 4DB⒎PME .BJM-JTU -JTU5JMF 1SPWJEFS -JTU5JMF -JTU5JMF

Slide 33

Slide 33 text

αϯϓϧΞϓϦ class MailList extends StatefulWidget { … } class _MailListState extends State { @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { // initState׬ྃޙʹϝʔϧΛऔಘ͢ΔΞΫγϣϯΛൃߦ context.read().fetchMails(); }); } …

Slide 34

Slide 34 text

αϯϓϧΞϓϦ class MailList extends StatefulWidget { … } class _MailListState extends State { @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { // initState׬ྃޙʹϝʔϧΛऔಘ͢ΔΞΫγϣϯΛൃߦ context.read().fetchMails(); }); } …

Slide 35

Slide 35 text

αϯϓϧΞϓϦ Widget build(BuildContext context) { // Providerܦ༝Ͱදࣔ͢΂͖ϝʔϧҰཡΛऔಘ final mails = context.watch().mails; return Container( child: ListView.builder( itemBuilder: (context, index) { return ListTile( … onTap: () async { // ListTileλοϓ࣌ʹϝʔϧৄࡉʹભҠ Navigator.of(context).pushNamed( MailDetail.routeName, arguments: mails[index], );

Slide 36

Slide 36 text

αϯϓϧΞϓϦͰςετ͍ͨ͠ϙΠϯτ w΢ΟδΣοτͷॳճϏϧυ࣌ʹϦΫΤετΛ࣮ߦͯ͠ϝʔϧΛऔಘ wϝʔϧΛλοϓ͢Δͱɺͦͷϝʔϧͷৄࡉը໘΁ભҠ

Slide 37

Slide 37 text

αϯϓϧΞϓϦͰςετ͍ͨ͠ϙΠϯτ w΢ΟδΣοτͷॳճϏϧυ࣌ʹϦΫΤετΛ࣮ߦͯ͠ϝʔϧΛऔಘ wϝʔϧΛλοϓ͢Δͱɺͦͷϝʔϧͷৄࡉը໘΁ભҠ

Slide 38

Slide 38 text

αϯϓϧΞϓϦͷ8JEHFU5FTU void main() { testWidgets("initialization", (WidgetTester tester) async { //ςετ༻ͷStoreΛ༻ҙ final store = MailStore(); expect(store.mails.length, 0); await tester.pumpWidget( // testerʹ౉͢΢ΟδΣοτΛProviderͰϥοϓ ChangeNotifierProvider.value( value: store, child: Home(), ), ); // Storeͷঢ়ଶΛݕূ expect(store.mails.length, 20);

Slide 39

Slide 39 text

αϯϓϧΞϓϦͷ8JEHFU5FTU void main() { testWidgets("initialization", (WidgetTester tester) async { //ςετ༻ͷStoreΛ༻ҙ final store = MailStore(); expect(store.mails.length, 0); await tester.pumpWidget( // testerʹ౉͢΢ΟδΣοτΛProviderͰϥοϓ ChangeNotifierProvider.value( value: store, child: Home(), ), ); // Storeͷঢ়ଶΛݕূ expect(store.mails.length, 20);

Slide 40

Slide 40 text

αϯϓϧΞϓϦͷ8JEHFU5FTU void main() { testWidgets("initialization", (WidgetTester tester) async { //ςετ༻ͷStoreΛ༻ҙ final store = MailStore(); expect(store.mails.length, 0); await tester.pumpWidget( // testerʹ౉͢΢ΟδΣοτΛProviderͰϥοϓ ChangeNotifierProvider.value( value: store, child: Home(), ), ); // Storeͷঢ়ଶΛݕূ expect(store.mails.length, 20);

Slide 41

Slide 41 text

αϯϓϧΞϓϦͷ8JEHFU5FTU void main() { testWidgets("initialization", (WidgetTester tester) async { //ςετ༻ͷStoreΛ༻ҙ final store = MailStore(); expect(store.mails.length, 0); await tester.pumpWidget( // testerʹ౉͢΢ΟδΣοτΛProviderͰϥοϓ ChangeNotifierProvider.value( value: store, child: Home(), ), ); // Storeͷঢ়ଶΛݕূ expect(store.mails.length, 20);

Slide 42

Slide 42 text

1SPWJEFSΛ൐͏8JEHFU5FTU wςετͷର৅͸6*Ͱ͸ͳ͘ɺ΢ΟδΣοτͷৼΔ෣͍ w௨ৗͷ8JEHFU5FTUͱൺֱ͢Δͱɺมߋʹڧ͍ wςετΛॻ͘ෛՙΛ཈͑ͭͭɺมߋʹڧ͍ΞϓϦΛ࡞Γ΍͘͢ͳΔ

Slide 43

Slide 43 text

·ͱΊ w8JEHFU5FTU͸໊લͷ௨Γ΢ΟδΣοτʹର͢Δςετ wίʔυͰ΢ΟδΣοτͷૢ࡞Λهड़Ͱ͖Δ wมߋʹऑ͍͕ɺ1SPWJEFSͱ૊Έ߹ΘͤΔͱৼΔ෣͍ͷςετ͕Ͱ͖Δ wৼΔ෣͍ͷςετ͸มߋʹڧ͍