How to run flutter test on chrome platform ? "No tests ran" when trying with starting project

Viewed 1998

In order to create a android/web app I want to run flutter tests on specific platforms. When I specify "chrome" I obtain "No tests ran." Of course app is working when I do "flutter run -d chrome"

The problem is easy to reproduce with flutter starting app. Here's what I've done on linux :

mkdir chrome_test
cd chrome_test
create .
flutter test test/

=> All tests passed!

When I add @TestOn("vm") at beginning of test/widget_test.dart => all tests passed!

When I add @TestOn("chrome") at beginning of test/widget_test.dart => No tests ran.

[✓] Flutter (Channel master, v1.10.6-pre.39, on Linux, locale fr_FR.UTF-8)
    • Flutter version 1.10.6-pre.39 at /home/rbarbe/programes/flutter
    • Framework revision 4815b26d71 (il y a 7 jours), 2019-09-24 00:21:44 -0700
    • Engine revision 953ac71749
    • Dart version 2.6.0 (build 2.6.0-dev.1.0 d53d355c6c)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/rbarbe/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /home/rbarbe/programes/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 3.3)
    • Android Studio at /home/rbarbe/programes/android-studio
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)

[✓] IntelliJ IDEA Community Edition (version 2019.1)
    • IntelliJ at /home/rbarbe/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/191.6183.87
    • Flutter plugin version 35.2.2
    • Dart plugin version 191.6183.88

[✓] IntelliJ IDEA Community Edition (version 2019.2)
    • IntelliJ at /home/rbarbe/.local/share/JetBrains/Toolbox/apps/IDEA-C/ch-0/192.6603.28
    • Flutter plugin version 39.0.5
    • Dart plugin version 192.6603.23

[✓] VS Code (version 1.38.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.4.1

[✓] Connected device (2 available)
    • Chrome • chrome • web-javascript • Google Chrome 77.0.3865.90
    • Server • web    • web-javascript • Flutter Tools

• No issues found!
1 Answers

Method (1)

  1. open a terminal

  2. go to root the directory of the project

  3. Type this => flutter run -d chrome --web-port 2021 test/home_test.dart or something like that

  4. wait for chrome to jump out

  5. see the results on the terminal!!

Note => change test/home_test.dart with your file name !.

I hope that will work for you!

if not try method (2). maybe you will find your answer!!

method (2) follow the steps given in the link carefully.

https://flutter.dev/docs/cookbook/testing/integration/introduction

Related