'How to write integration test in provider
Could not find appbar title "Exam Start"
await tester.pump(Duration(seconds: 1));
final titleFinder = find.text("Exam start");
expect(titleFinder, findsOneWidget);
my provider implementation is given below.
return MultiProvider(
providers: [
// Provider(create: (context) => RadioModel()),
ChangeNotifierProvider(
// Initialize the model in the builder. That way, Provider
// can own Counter's lifecycle, making sure to call `dispose`
// when not needed anymore.
create: (context) => RadioModel(),
//child: const MyApp(),
),
ChangeNotifierProvider(
// Initialize the model in the builder. That way, Provider
// can own Counter's lifecycle, making sure to call `dispose`
// when not needed anymore.
create: (context) => CheckModel(),
//child: const MyApp(),
),
],
child: Scaffold(
backgroundColor: AppColors.background,
appBar: AppBarHelper.getAppBar(context,
title: "Exam start", showBackOption: true, elevation: 0),
resizeToAvoidBottomInset: false,
body: Container(
margin: EdgeInsets.all(15),
child: Stack(
children: [
StreamBuilder<Resource<QuestionlistBaseModel>>(
stream: widget.bloc.questionListStream,
builder: (BuildContext context, snapshot) {
if (snapshot.data == null ||
snapshot.data?.status == ResourceStatus.LOADING) {
return Center(
child: CircularProgressIndicator(),
);
} else if (snapshot.data?.status ==
ResourceStatus.SUCCESS) {
loadingPublisher.sink.add(false);
quizTime = snapshot.data?.model?.quizTime ?? 0;
userExamId = snapshot.data!.model!.userExamId.toString();
questionsList.clear();
questionsList
.addAll(snapshot.data?.model?.questions ?? []);
if (isTimeCountStart) {
startTimeout(quizTime);
}
return SingleChildScrollView(
child: Column(
children: [
getTimerProgressbar(),
Consumer<CounterModel>(builder: (newContext, _counterModel, child) {
return Column(
children: [
Card(
margin: EdgeInsets.all(10),
elevation: 1,
child: getQuestionUi(
questionsList[_counterModel.counter]),
),
Container(
margin: EdgeInsets.all(15),
child: getBottomButton(_counterModel)),
],
); // use this
}),
],
),
);
} else if (snapshot.data?.status == ResourceStatus.FAILED) {
loadingPublisher.sink.add(false);
return Center(child: Text(snapshot.data?.message ?? ''));
}
return Center(child: Text(snapshot.data?.message ?? ""));
},
),
],
),
),
),
);
`How can I get view(button image text or etc ) acccess from the inner of body container? I have a set of question and answer list in my widget, user have to select radiogroup/checkbutton/input test from multiple answer. If user finished one of them, he will get the access of the next question by pressing the next button. For integrating test first I have to find those answer view with title/id/key after that need to automically select one of them and press the next button. But unfortunately I couldn't get the view!!! Ui design is given below. screnshoot url == screenshoot url
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|