Skip to content

Flutter Test should support multiple reporters #69425

@danilofuchs

Description

@danilofuchs

Use case

When running flutter test on a CI, output is very verbose and hard to follow:

image
(this goes on for 200+ lines)

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.xml

By 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: tests"flutter test", flutter_test, or one of our testsc: proposalA detailed proposal for a change to FluttertoolAffects 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