Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Best strategy for testing my app #202

Closed
aBuder opened this issue Jun 18, 2019 · 3 comments
Closed

Best strategy for testing my app #202

aBuder opened this issue Jun 18, 2019 · 3 comments

Comments

@aBuder
Copy link

aBuder commented Jun 18, 2019

I have an app and use your parse server sdk. To test my app I wrote test cases. If I start my tests the sdk would be break. Is there are an solution to mock the parse connection? In my case I wrote an bloc and the bloc create an new ParseObject. My test break on creating the new object.

So I would like to discuss how to mock parse server lib to mock ParseObjects and connection.

My Bloc

import 'package:bloc/bloc.dart';
import 'package:parse_server_sdk/parse_server_sdk.dart';
import 'plan_create_event.dart';
import 'plan_create_state.dart';

/// Bloc for plan create screen, which handle incoming events
/// and return states.
class PlanCreateBloc extends Bloc<PlanCreateEvent, PlanCreateState> {
  ParseObject plan = new ParseObject('Plan');

  @override
  PlanCreateState get initialState => Initial();

  Stream<PlanCreateState> _mapLoadPlansToState(PlanCreateSave event) async* {
    // set sate to saving
    yield Saving();

    // fetch plans form repository
    var name = event?.name ?? "";
    var text = event?.text ?? "";
    var weeks = event?.weeks ?? 10;

    var user = await ParseUser.currentUser();
    var startedAt = DateTime.now();
    var endedAt = startedAt.add(Duration(days: weeks * 7));
    plan
      ..set('name', name)
      ..set('text', text)
      ..set('user', user)
      ..set('startedAt', startedAt)
      ..set('endedAt', endedAt)
      ..set('isTemplate', false)
      ..set('minRepetition', 0)
      ..set('isMailSended', false);

    ParseResponse response = await this.plan.save();

    if (response?.success ?? false) {
      yield Saved(plan: plan);
    } else {
      yield Error();
    }
  }

  Stream<PlanCreateState> _mapPlanNavigationCompleteToState() async* {
    yield Initial();
  }

  @override
  Stream<PlanCreateState> mapEventToState(PlanCreateEvent event) async* {
    if (event is PlanCreateSave) {
      yield* _mapLoadPlansToState(event);
    }
    if (event is PlanNavigationComplete) {
      yield* _mapPlanNavigationCompleteToState();
    }
  }
}
import 'package:Butterfly/bloc/plan_create/bloc.dart';
import 'package:Butterfly/common/common.dart';
import 'package:Butterfly/localization/localization.dart';
import 'package:Butterfly/screen/plan_items_edit/plan_exercises_screen.dart';
import 'package:Butterfly/widgets/error_container_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class PlanCreateScreen extends StatefulWidget {
  @override
  _PlanCreateScreenState createState() => _PlanCreateScreenState();
}

class _PlanCreateScreenState extends State<PlanCreateScreen> {
  PlanCreateBloc bloc;
  TextEditingController nameController = TextEditingController();
  TextEditingController textController = TextEditingController();
  double weeks = 10.0;

  @override
  void initState() {
    bloc = PlanCreateBloc();
    bloc.dispatch(PlanNavigationComplete());
    nameController.text = bloc.plan.get<String>('name');
    textController.text = bloc.plan.get<String>('text');
    super.initState();
  }

  @override
  void dispose() {
    bloc.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          CustomLocalizations.of(context).forKey('0498'),
        ),
        elevation: 0.0,
      ),
      body: BlocBuilder<PlanCreateEvent, PlanCreateState>(
        bloc: bloc,
        builder: (BuildContext context, PlanCreateState state) {
          // if sate is initial
          if (state is Initial) {
            return Stack(
              alignment: AlignmentDirectional.bottomCenter,
              children: <Widget>[
                Form(
                  child: ListView(
                    children: <Widget>[
                      SizedBox(
                        height: 32,
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(
                          horizontal: 16,
                        ),
                        child: Text(
                          "Name",
                          style: TextStyle(
                            fontSize: 19,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.symmetric(
                          horizontal: 16.0,
                          vertical: 4.0,
                        ),
                        child: TextFormField(
                          controller: this.nameController,
                          decoration: new InputDecoration(
                            filled: true,
                            hintText: "Trage den Namen hier ein",
                          ),
                          enableInteractiveSelection: false,
                        ),
                      ),
                      SizedBox(
                        height: 32,
                      ),
                      Padding(
                        padding: const EdgeInsets.symmetric(
                          horizontal: 16,
                        ),
                        child: Text(
                          "Beschreibung",
                          style: TextStyle(
                            fontSize: 19,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ),
                      Container(
                        margin: EdgeInsets.symmetric(
                          horizontal: 16.0,
                          vertical: 4.0,
                        ),
                        child: TextFormField(
                          maxLines: 3,
                          controller: this.textController,
                          decoration: new InputDecoration(
                            filled: true,
                            hintText:
                                "Trage hier eine kurze Beschreibung hier ein",
                          ),
                          enableInteractiveSelection: false,
                        ),
                      ),
                      SizedBox(
                        height: 32,
                      ),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Padding(
                            padding: const EdgeInsets.symmetric(
                              horizontal: 16,
                            ),
                            child: Text(
                              "Laufzeit",
                              style: TextStyle(
                                fontSize: 19,
                                fontWeight: FontWeight.bold,
                              ),
                            ),
                          ),
                          Slider(
                            activeColor: Colors.blueAccent,
                            min: 1.0,
                            max: 16.0,
                            onChanged: (value) {
                              setState(() {
                                weeks = value.toInt().toDouble();
                              });
                            },
                            value: weeks,
                          ),
                          Container(
                            padding: EdgeInsets.only(top: 18.0),
                            child: Center(
                              child: Text(
                                "${weeks.toInt()} Wochen",
                                style: TextStyle(
                                  fontSize: 24,
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
                Container(
                  padding: EdgeInsets.only(
                    left: 16,
                    right: 16,
                    bottom: 24,
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: <Widget>[
                      ButtonTheme(
                        height: 45,
                        child: RaisedButton(
                          onPressed: () {
                            var event = PlanCreateSave(
                              name: nameController.text,
                              text: textController.text,
                              weeks: weeks.toInt(),
                            );
                            bloc.dispatch(event);
                          },
                          child: Text(
                            "Weiter",
                          ),
                          color: Colors.blueAccent,
                          textColor: Colors.white,
                          elevation: 2,
                          shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(
                              8.0,
                            ),
                          ),
                        ),
                      )
                    ],
                  ),
                ),
              ],
            );
          }

          // if state is saved
          if (state is Saved) {
            SchedulerBinding.instance.addPostFrameCallback(
              (_) async {
                Route route = MaterialPageRoute(
                  builder: (context) => PlanItemsEditScreen(
                    plan: state?.plan,
                  ),
                );
                await Navigator.of(context).push(route);
              },
            );
            bloc.dispatch(PlanNavigationComplete());
          }
          // if state is saving
          if (state is Saving) {
            return LoadingWidget();
          }

          // if state is error
          if (state is Error) {
            return ErrorContainerWidget(
              onTap: () {
                bloc.dispatch(PlanNavigationComplete());
              },
            );
          }

          // default display Column
          return Column();
        },
      ),
    );
  }
}

My Test

import 'package:Butterfly/localization/localization.dart';
import 'package:Butterfly/screen/plan_create/plan_create_screen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {

  MaterialApp buildMaterialApp(Widget child) {
    return new MaterialApp(
      locale: Locale('de'),
      supportedLocales: [
        const Locale('de'),
      ],
      localizationsDelegates: [
        CustomLocalizationsDelegate(),
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
      ],
      home: child,
    );
  }

  testWidgets('Check state initial', (WidgetTester tester) async {
    PlanCreateScreen screen = PlanCreateScreen();
    MaterialApp app = buildMaterialApp(screen);
    await tester.pumpWidget(app);
    expect(find.byType(Stack), findsOneWidget);
  });

}

Log

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building Builder:
The getter 'debug' was called on null.
Receiver: null
Tried calling: debug

When the exception was thrown, this was the stack:
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
#1      isDebugEnabled (package:parse_server_sdk/src/utils/parse_utils.dart:8:47)
#2      new ParseObject (package:parse_server_sdk/src/objects/parse_object.dart:15:14)
#3      new PlanCreateBloc (package:Butterfly/bloc/plan_create/plan_create_bloc.dart:10:26)
#4      _PlanCreateScreenState.initState (package:Butterfly/screen/plan_create/plan_create_screen.dart:23:12)
#5      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3978:58)
#6      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#7      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#8      Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#9      SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#10     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#11     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#12     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#13     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#14     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#15     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#16     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#17     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#18     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#19     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#20     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#21     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#22     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#23     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#24     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#25     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#26     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#27     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#28     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#29     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#30     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#31     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#32     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#33     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#34     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#35     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#36     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#37     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#38     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#39     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#40     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#41     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#42     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#43     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#44     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#45     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#46     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#47     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#48     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#49     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#50     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#51     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#52     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#53     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#54     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#55     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#56     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#57     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#58     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#59     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#60     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#61     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#62     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#63     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#64     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#65     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#66     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#67     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#68     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#69     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#70     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#71     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#72     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#73     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#74     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#75     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#76     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#77     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#78     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#79     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#80     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#81     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#82     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#83     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#84     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#85     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#86     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#87     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#88     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#89     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#90     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#91     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#92     Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#93     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#94     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#95     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#96     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#97     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5124:32)
#98     Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#99     Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#100    _TheatreElement.mount (package:flutter/src/widgets/overlay.dart:593:16)
#101    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#102    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#103    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#104    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#105    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#106    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#107    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#108    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#109    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#110    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#111    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#112    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#113    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#114    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#115    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#116    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#117    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#118    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#119    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#120    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#121    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#122    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#123    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#124    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#125    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#126    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#127    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#128    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#129    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#130    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#131    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#132    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#133    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#134    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#135    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#136    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#137    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#138    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#139    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#140    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#141    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#142    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#143    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#144    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#145    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#146    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#147    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#148    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#149    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#150    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#151    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#152    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#153    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#154    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#155    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#156    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#157    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#158    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#159    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#160    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#161    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#162    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#163    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#164    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#165    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#166    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#167    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#168    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#169    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#170    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#171    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#172    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#173    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#174    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#175    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#176    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#177    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#178    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#179    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#180    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#181    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#182    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#183    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#184    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#185    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#186    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#187    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#188    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#189    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#190    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#191    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#192    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#193    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#194    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#195    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#196    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#197    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#198    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#199    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#200    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#201    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#202    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#203    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#204    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#205    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#206    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#207    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#208    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#209    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#210    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#211    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#212    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#213    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#214    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#215    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#216    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#217    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#218    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#219    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#220    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#221    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#222    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#223    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#224    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#225    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#226    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#227    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5018:14)
#228    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#229    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#230    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#231    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#232    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#233    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#234    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#235    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#236    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#237    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#238    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#239    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#240    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#241    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#242    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#243    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#244    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#245    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#246    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#247    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#248    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#249    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#250    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#251    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#252    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#253    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#254    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#255    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#256    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#257    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#258    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#259    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#260    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#261    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#262    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3882:16)
#263    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#264    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3854:5)
#265    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3996:11)
#266    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3849:5)
#267    Element.inflateWidget (package:flutter/src/widgets/framework.dart:3055:14)
#268    Element.updateChild (package:flutter/src/widgets/framework.dart:2858:12)
#269    RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:939:16)
#270    RenderObjectToWidgetElement.update (package:flutter/src/widgets/binding.dart:917:5)
#271    RenderObjectToWidgetElement.performRebuild (package:flutter/src/widgets/binding.dart:931:7)
#272    Element.rebuild (package:flutter/src/widgets/framework.dart:3668:5)
#273    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2317:33)
#274    AutomatedTestWidgetsFlutterBinding.drawFrame (package:flutter_test/src/binding.dart:934:18)
#275    _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding&GestureBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
#276    _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15)
#277    _TestWidgetsFlutterBinding&BindingBase&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9)
#278    AutomatedTestWidgetsFlutterBinding.pump.<anonymous closure> (package:flutter_test/src/binding.dart:847:9)
#281    TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#282    AutomatedTestWidgetsFlutterBinding.pump (package:flutter_test/src/binding.dart:834:27)
#283    WidgetTester.pumpWidget.<anonymous closure> (package:flutter_test/src/widget_tester.dart:301:22)
#286    TestAsyncUtils.guard (package:flutter_test/src/test_async_utils.dart:69:41)
#287    WidgetTester.pumpWidget (package:flutter_test/src/widget_tester.dart:298:27)
#288    main.<anonymous closure> (file:///Users/abuder/projects/butterfly/butterfly-member/test/screen/plan_create/plan_create_test.dart:29:18)
#290    main.<anonymous closure> (file:///Users/abuder/projects/butterfly/butterfly-member/test/screen/plan_create/plan_create_test.dart:26:38)
#291    testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:118:25)
#293    testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:117:9)
#294    TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:630:19)
#308    AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1026:17)
#310    AutomatedTestWidgetsFlutterBinding.runTest.<anonymous closure> (package:flutter_test/src/binding.dart:1014:35)
(elided 35 frames from class _FakeAsync, package dart:async, package dart:async-patch, and package stack_trace)
════════════════════════════════════════════════════════════════════════════════════════════════════
Test failed. See exception logs above.
The test description was: Check state initial

✖ Check state initial
Exited (1)
@aBuder aBuder changed the title Best architecture for testing my app Best strategy for testing my app Jun 18, 2019
@phillwiggins
Copy link
Member

phillwiggins commented Jun 18, 2019 via email

@phillwiggins
Copy link
Member

Actually, I can't see where you initialise the Parse library. Look at the docs for initialising Parse.

@aBuder
Copy link
Author

aBuder commented Jun 20, 2019

That's right. I have to initialize Parse in setUp method.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants