This Dart script is designed to run Flutter tests, process the results, and generate a JSON report of the test outcomes. It uses Flutter's testing framework and custom extensions to adapt the results for Gradescope or similar platforms.
Class-specific tests should not ever be added to this repo.
- Load Configuration: Reads configuration from a JSON file to determine which tests to run.
- Run Linter: Executes the Flutter linter to check for code issues.
- Run Tests: Executes Flutter tests based on configuration.
- Process Results: Collects and processes test results.
- Generate Report: Outputs the results into a JSON file for further analysis or submission.
- Dart SDK
- Flutter SDK
dart_test_adapter
package- Custom Dart files for test results and extensions
run_autograder adds the necessary dependencies
- test_result.dart: Contains custom classes for handling test results.
- test_runner_extension.dart: Includes extensions for running tests.
- config.json: Configuration file with test details.
Setup Configuration File
Create a config.json file in the dart/flutter project's test/course_tests/gradescope_flutter/ directory :
Example config.json file: "docs/example/config.json"
Run the Script
Execute the script using the Dart/Flutter SDK:
flutter test 'test/course_tests/gradescope_flutter/gradescope_run_test.dart' (run_autograder takes care of executing this command)
Result The results will be written to ../results/results.json. This file will include:
A list of test results with names, scores, and statuses. Total execution time. Total score.
An example of such output is provided in docs/example/test_results.json
- File Not Found: If the configuration file is missing, the script will handle it gracefully and print an error message.
- Test Failures: The script captures and reports any errors during test execution.
Adjust the timeout value in the script as needed for your test environment. Make sure the specified file paths are correct and accessible.
Feel free to contribute to the codebase by submitting pull requests or reporting issues.