Skip to content

flutter test does not understand concurrency #125940

@fzyzcjy

Description

@fzyzcjy

Possible fix: Mimic #115160

Is there an existing issue for this?

Steps to reproduce

flutter test

Expected results

Tests should be executed one-by-one, since we specify concurrency=1 in dart_test.yaml

Actual results

They are executed parallelly.

flutter test
00:02 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=0)
00:02 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=0)
00:02 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=0)
00:03 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=1)
00:03 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=1)
00:03 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=1)
00:03 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=2)
00:03 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=2)
00:03 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=2)
00:04 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=3)
00:04 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=3)
00:04 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=3)
00:04 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=4)
00:04 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=4)
00:04 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=4)
00:05 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=5)
00:05 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=5)
00:05 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=5)
00:05 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=6)
00:05 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=6)
00:05 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=6)
00:06 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=7)
00:06 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=7)
00:06 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=7)
00:06 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=8)
00:06 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=8)
00:06 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=8)
00:07 +0: /Users/tom/RefCode/bug/test/c_test.dart: hello this is test                                                                         
c_test is running (i=9)
00:07 +0: /Users/tom/RefCode/bug/test/b_test.dart: hello this is test                                                                         
b_test is running (i=9)
00:07 +0: /Users/tom/RefCode/bug/test/a_test.dart: hello this is test                                                                         
a_test is running (i=9)
00:07 +3: All tests passed!

Code sample

Code sample

dart_test.yaml

concurrency: 1

test/a_test.dart

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
void main() {
  test('hello this is test', () {
    for (var i = 0; i < 10; ++i) {
      print('a_test is running (i=$i)');
      sleep(const Duration(milliseconds: 500));
    }
  });
}

test/b_test.dart

same, just change the name in "print", i.e.

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
void main() {
  test('hello this is test', () {
    for (var i = 0; i < 10; ++i) {
      print('b_test is running (i=$i)');
      sleep(const Duration(milliseconds: 500));
    }
  });
}

test/c_test.dart

similar to b_test.dart

import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
void main() {
  test('hello this is test', () {
    for (var i = 0; i < 10; ++i) {
      print('c_test is running (i=$i)');
      sleep(const Duration(milliseconds: 500));
    }
  });
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our testsdependency: dart:ioIssue in 'dart:io' libraryfound in release: 3.10Found to occur in 3.10found in release: 3.7Found to occur in 3.7has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versiontoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions