0

Is it possible to force one or more tests in a test suite to run separately and serially in dart/flutter?

Note: I'm not looking to run a single test via CLI filters. I want to be able to run my full test suite as part of my CI flow.

Example

The test runner ava is able to do this in javascript via the serial modifier:

test.serial('passes serially', t => {
    t.pass();
});

https://github.com/avajs/ava/blob/main/docs/01-writing-tests.md#running-tests-serially

Context

I'm using a third-party library to communicate and authenticate with my backend server. This library makes use of a singleton to make accessing the current user "easier". However, it makes integration testing in parallel impossible since the testing process can only mimic a single user at a time, which in turn makes tests interfere with each other.

Felix ZY
  • 674
  • 6
  • 14

1 Answers1

0

If you run "flutter test" in your CI all your tests in the project will be run in serial. No need to do something extra for that.

Mark Toten
  • 61
  • 3
  • 1
    From what I've read, flutter tests seem to run in parallel by default. See e.g. https://github.com/Dart-Code/Dart-Code/issues/2957 . Do you have documentation stating otherwise? – Felix ZY Feb 05 '23 at 13:41
  • I was in the impression that they ran serially when running them looking at how the results come back and all the test always finish in the same order as specified in the files. running with -j 1 would solve your problem, right? I do have the feeling that this conncurrency option is more about how many cores a process can use and not the number of parallel test. See also, i.e. https://stackoverflow.com/questions/64846907/how-to-do-test-sharding-or-run-in-parallel-for-flutter – Mark Toten Feb 05 '23 at 13:59