Skip to content

feat: Export raw results into csv format#27

Merged
deicon merged 2 commits intodevelopfrom
feat/chart-reports
Oct 28, 2025
Merged

feat: Export raw results into csv format#27
deicon merged 2 commits intodevelopfrom
feat/chart-reports

Conversation

@deicon
Copy link
Owner

@deicon deicon commented Oct 26, 2025

Description:
Adds a shortcut flag -csv to output CSV reports directly to stdout when using the -raw option for offline reporting.

Motivation:
The existing -raw reporting functionality allows generating reports from raw result files. However, outputting CSV reports required specifying the -report and -output flags, creating a file on disk. This change simplifies the process of generating and viewing CSV reports directly in the terminal, especially useful for quick analysis and scripting.

What was changed:

  • Modified cmd/httprunner/main.go to add the -csv flag.
  • When the -csv flag is present, it forces -report=csv and -detail=summary, and outputs to stdout
  • Added a check to ensure -csv is used together with -raw, exiting with an error otherwise

Tests:

  • Added a new test case TestOfflineCSVShortcutPrintsToStdout in cmd/httprunner/main_test.go to verify the new functionality. This test creates a temporary results file, executes the runner with the -raw and -csv flags, and asserts that the CSV output is printed to stdout and contains the expected data.

@deicon deicon requested a review from Copilot October 26, 2025 14:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a -csv shortcut flag to simplify generating CSV reports from raw result files by outputting directly to stdout instead of requiring file output configuration.

Key changes:

  • Added -csv flag that automatically sets -report=csv and -detail=summary when used with -raw
  • Modified output logic to print CSV to stdout when -csv is active
  • Added validation to ensure -csv is only used with -raw

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/httprunner/main.go Implements the -csv flag, validation logic, and stdout output behavior
cmd/httprunner/main_test.go Adds test coverage for the new -csv flag functionality
Comments suppressed due to low confidence (1)

cmd/httprunner/main.go:1

  • The test calls main() which will execute os.Exit() on error paths, potentially terminating the test process. Consider refactoring main logic into a testable function that returns errors instead of calling os.Exit(), allowing better test isolation and error handling.
package main

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@deicon deicon changed the title feat: Export raaw results into csv format feat: Export raw results into csv format Oct 28, 2025
@deicon deicon merged commit 4e7739d into develop Oct 28, 2025
12 checks passed
@deicon deicon deleted the feat/chart-reports branch October 28, 2025 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant