How can the code coverage data from Flutter tests be displayed?

后端 未结 6 670
别那么骄傲
别那么骄傲 2020-12-25 11:23

I\'m working on a Flutter app using Android Studio as my IDE.
I\'m attempting to write tests and check the code coverage but I can\'t work out how to view the data in th

6条回答
  •  一向
    一向 (楼主)
    2020-12-25 12:15

    You can use SonarQube with an additional plugin for Flutter as per this link SonarQube plugin for Flutter / Dart.

    I have tried it with the free version of SonarQube on docker, and if you have configured it correctly, you just need to run the following commands on Android Studio terminal:

    # Download dependencies 
    flutter pub get 
    # Run tests
    flutter test --machine > tests.output
    # Compute coverage (--machine and --coverage cannot be run at once...)
    flutter test --coverage
    # Run the analysis and publish to the SonarQube server
    sonar-scanner
    

    Here is the sample of the report, and you can drill deep into line codes. Valid XHTML

提交回复
热议问题