Flutter Test should support multiple reporters #69425
Description
Use case
When running flutter test on a CI, output is very verbose and hard to follow:
The current alternative is to output to json with flutter test --machine. This is even more verbose, but can be converted to JUnit XML so we can use a specialized test visualization tools, such as Bitrise Test Reports.
This does the job, but requires a lot of configuration and there is currently no way of having two reporters at the same time.
If I want both CLI output and JSON, I need to run tests twice.
I want to be able to output to any format while still having a console output (customizable as well).
Proposal
Flutter should have a --reporter CLI option, inspired by Mocha Reporters or Jest Reporters.
# Current output if not in CI environment
flutter test
# Simple, CI friendly output
flutter test --reporter spec
# Minimal output with number of passes AND json output to test_results.json file
flutter test --reporter min --reporter json --reporter-option output=test_results.json
# JUnit XML report out of the box
flutter test --reporter xunit --reporter-option output=test_results.xmlBy default Flutter will use the current reporter. If env CI=true, flutter will use spec automatically.
This is an idea we can take from the very well established and mature JS ecosystem.

Activity
ogezue commentedon Aug 8, 2022
is there something on the market that can be used instead?
nico-famedly commentedon Aug 8, 2022
Dart supports the --file-reporter option: https://github.com/dart-lang/test/blob/master/pkgs/test/doc/json_reporter.md#usage
It would be nice if flutter supported that too.
allow passing --file-reporter option to test running refs flutter#69425
bartekpacia commentedon Oct 22, 2022
flutter testdoes have a--reporterargument, which acceptscompact,expanded, andjson. Is this what you're looking for?danilofuchs commentedon Oct 22, 2022
The main goal is outputting to more than one reporter at the same time. So JSON + expanded in a single run.
Optionally, allow custom reporters, for developing plugins for jUnit XML, ...
allow passing --file-reporter option to test running refs #69425 (#12…
github-actions commentedon Mar 7, 2023
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.