Skip to content

Instantly share code, notes, and snippets.

View tianhaoz95's full-sized avatar

Tianhao Zhou tianhaoz95

View GitHub Profile
@tianhaoz95
tianhaoz95 / flutter_build_artifact.yml
Created October 17, 2019 06:32
Flutter build artifact
name: Upload build artifact
on:
push:
branches:
- "master"
- "actions/*"
paths:
- "iwfpapp/**"
- ".github/**"
jobs:
@tianhaoz95
tianhaoz95 / flutter_deploy_docs.yml
Created October 17, 2019 06:35
Flutter deploy docs
name: Documentation
on:
push:
branches:
- "master"
jobs:
deploy:
name: Generate documentation
runs-on: ubuntu-latest
steps:
@tianhaoz95
tianhaoz95 / basic_widget_test.dart
Created October 23, 2019 19:37
Basic widget testing
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'demo',
home: Scaffold(
appBar: AppBar(
title: Text('demo title'),
),
body: Center(
@tianhaoz95
tianhaoz95 / setup.dart
Created October 24, 2019 02:26
Demo app setup
/// main.dart (the entry point to the demo app)
import 'package:flutter/material.dart';
import 'package:demo_async_test/contrib.dart';
import 'package:demo_async_test/slow.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@tianhaoz95
tianhaoz95 / test.dart
Created October 24, 2019 02:33
demo widget tests
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:demo_async_test/main.dart';
void main() {
testWidgets('Counter increments', (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
expect(find.text('0'), findsOneWidget);
await tester.tap(find.byIcon(Icons.add));
@tianhaoz95
tianhaoz95 / test_incr.dart
Created October 24, 2019 03:45
Test incrementing click count
testWidgets('Counter increments', (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
expect(find.text('0'), findsOneWidget);
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
expect(find.text('1'), findsOneWidget);
});
@tianhaoz95
tianhaoz95 / test_nav.dart
Created October 24, 2019 03:47
Test navigation
testWidgets('Contrib screen shows up', (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
await tester.tap(find.byKey(Key('contrib_btn')));
await tester.pumpAndSettle();
expect(find.byKey(Key('contrib_title')), findsOneWidget);
});
@tianhaoz95
tianhaoz95 / test_unknown_delay.dart
Created October 24, 2019 04:04
Test unknown delay in widget test
testWidgets('Slow screen content shows up', (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
await tester.tap(find.byKey(Key('slow_btn')));
await tester.pumpAndSettle(new Duration(seconds: 5));
expect(find.byKey(Key('slow_content')), findsOneWidget);
});
@tianhaoz95
tianhaoz95 / jest_like_test.dart
Created October 26, 2019 05:45
Jest like test
testWidgets('Counter increments', (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
expect(find.text('0'), findsOneWidget);
await tester.tap(find.byIcon(Icons.add));
expect(find.text('1'), findsOneWidget);
});
@tianhaoz95
tianhaoz95 / stupid_test.dart
Created October 26, 2019 05:53
Stupid test
testWidgets('Contrib screen shows up', (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
await tester.tap(find.byKey(Key('contrib_btn')));
await tester.pump();
await tester.pump();
// and many more pump...
await tester.pump();
await tester.pump();
await tester.pump();
expect(find.byKey(Key('contrib_title')), findsOneWidget);