0

I have created the basic workout app with some pages. Also implemented the integration test code for main.dart(HomePage). But after executing the test file screen is getting loaded and stuck, afetr some time showing the Timeout error.

feature file and step file:

Feature: Home Screen

  Scenario: User sees the Welcome Screen on App launch
    Given the user opens the app and should see the "Welcome" text
    Then the user should see the "Login" button
    And the user should see the "Sign up" button


import 'package:flutter_driver/flutter_driver.dart';
import 'package:flutter_gherkin/flutter_gherkin.dart';
import 'package:gherkin/gherkin.dart';

class OpenTheApp extends Given1WithWorld<String, FlutterWorld> {
  @override
  RegExp get pattern =>
      RegExp(r"the user opens the app and should see the {string} text");

  @override
  Future<void> executeStep(String expectedText) async {
    final textInputFinder = find.byValueKey(expectedText);
    final FlutterDriver? driver = world.driver;
    await driver?.waitFor(textInputFinder, timeout: Duration(seconds: 240));
    final text = await driver?.getText(textInputFinder);
    expect(text, expectedText);
  }
}

class SeeLoginButton extends Given1WithWorld<String, FlutterWorld> {
  @override
  RegExp get pattern =>
      RegExp(r"the user should see the {string} button");

  @override
  Future<void> executeStep(String loginbtn) async {
    final loginfinder = find.byValueKey(loginbtn);
    await FlutterDriverUtils.tap(world.driver, loginfinder);
  }
}

class SeeSigninButton extends Given1WithWorld<String, FlutterWorld> {
  @override
  RegExp get pattern =>
      RegExp(r"the user should see the {string} button");

  @override
  Future<void> executeStep(String signinbtn) async {
    final signinfinder = find.byValueKey(signinbtn);
    await FlutterDriverUtils.tap(world.driver, signinfinder);
  }
}

I have added all the dependecies correctly and tried with emulator as well as physical devices facing same issue with each. Also tries the integartion test of the flutter default application by creating new project but facing same issue.

Test files are :

app.dart and test_config.dart :

import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:workout_app/Pages/main.dart';
void main() {
// This line enables the extension.
  enableFlutterDriverExtension();
  runApp(MyApp());
}


import 'dart:async';
import 'package:flutter_gherkin/flutter_gherkin.dart';
import 'package:gherkin/gherkin.dart';
import 'package:glob/glob.dart';
import 'step_definitions/home_screen_steps.dart';

Future<void> main() {
  final config = FlutterTestConfiguration()
    ..features = [Glob(r"test_driver/features/**.feature")]
    ..reporters = [ProgressReporter()]
    ..stepDefinitions = [OpenTheApp()]
    ..restartAppBetweenScenarios = true
    ..targetAppPath = "test_driver/app.dart"
    ..keepAppRunningAfterTests = false;
  return GherkinRunner().execute(config);
}
Priti M
  • 17
  • 6

0 Answers0