go-test-parser

module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2025 License: MIT

README

go-test-parser

An advanced research tool for identifying and analyzing unit tests in Go projects.

License Release

Features

  • Parse and analyze Go test files.
  • Generate detailed reports on test statistics and analysis.
  • Support for various output formats, including CSV and plaintext.

Quick Start

Download the latest binary for your operating system from the Releases page.

Application Options

Below is a list of the command-line options supported by the application:

Option Description Default Value Example Argument
--project / -p Path to the Go project directory to be parsed Required C:/programs/my-go-project, ./other-project
--output / -o Path to report output file Required ./output/report.csv, stats-report.txt
--append Whether to append to the output file instead of overwriting it false N/a
--splitByDir Whether to parse each top-level directory separately false N/a
--threads The number of concurrent threads to use for parsing (only when splitting by directory) 4 2, 8
--logLevel / -l The minimum severity of log message that should be displayed info debug, info, warn, error
--timer Whether to print the total execution time of the specified task false N/a

To access the help menu and see all available options, run:

./go-test-parser --help

Commands

Statistics

The statistics command analyzes the Go test files in the specified project directory and generates various statistics related to the project's test cases. This includes metrics such as the total number of test cases, number of test files, average test length, and the percentage of the project comprised of test code (by lines).

Supports output to either .txt or .csv files. Output is especially well-suited for a .csv file if using the splitByDir option.

Example:

./go-test-parser statistics --project ./my-go-project --output ./output/statistics-report.csv
Analyze

The analyze command performs a deeper analysis of the test cases in a project. This command identifies various structural elements in each test, with a focus on table-driven test indicators. The results of analyzing the tests are saved in their own JSON files, which are put in a new folder in the same directory as the output file. The JSON files are named like <project>/<project>_<package>_<testcase>.json.

Supports output to either .txt or .csv files. Output is especially well-suited for a .csv file because it will contain a condensed version of the analysis results of every test case.

Example:

./go-test-parser analyze --project ./my-go-project --output ./output/analyze-report.csv

Contributing

Contributions are welcome! Please feel free to submit Issues or Pull Requests!

License

This project is licensed under the MIT License. See the LICENSE file for details.

Directories

Path Synopsis
cmd
testparser command
Main application entry point
Main application entry point
internal
filewriter
Includes functions for actually writing data to files of various formats.
Includes functions for actually writing data to files of various formats.
pkg
parser
General-purpose parser for Go source files, using the Task interface to specify behavior.
General-purpose parser for Go source files, using the Task interface to specify behavior.
testcase
Provides functionality for storing and analyzing test cases extracted from Go source files.
Provides functionality for storing and analyzing test cases extracted from Go source files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL