I am testing a flutter application. I am to run an integration testing, just like Espresso and Selenium allow UI testing, based on my reading, I got to understand that testing Flutter UI will require setting up the integration model. In Selenium findById and Espresso, we can use , R.id.unique_element_id.
I have tried undertsanding the unique id to reference widgets in Flutter but do not understand. Any simple test for a form like this
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Text(
'You have pushed the button this many times:',
),
new TextFormField(
decoration: new InputDecoration(
labelText: 'Enter your username'
),
),
new TextFormField(
decoration: new InputDecoration(
labelText: 'Enter your phone number'
),
keyboardType: TextInputType.number,
),
new Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
Setup the test file like this
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
void main() {
FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
if(driver != null){
driver.close();
}
});
test('tap on the button, verify result', () async {
final SerializableFinder username = find.byValueKey('usernametextfield');
expect(username, isNotNull);
//insert value into username
final SerializableFinder phonenumber = find.byValueKey('phone');
expect(phonenumber, isNotNull);
//insert value into phonenumber
});
How do I create such a tetscase and run. the comments //insert value into username and //insert value into phonenumber are actual testcases I want to complete.
