The gotestsum is a tool designed to improve the process of running tests in Go. It provides a more user-friendly and readable output for Go test results, especially when running tests in CI/CD pipelines. This tutorial explains how to install gotestsum on Ubuntu 24.04.
Prepare environment
Make sure Go is installed on your system before starting. You can find installation instructions in a different post.
Install gotestsum
Check the newest version of gotestsum from GitHub repository and store it in a variable:
GOTESTSUM_VERSION=$(curl -s "https://api.github.com/repos/gotestyourself/gotestsum/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
Download gotestsum archive file:
wget -qO gotestsum.tar.gz https://github.com/gotestyourself/gotestsum/releases/latest/download/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz
Extract executable to /usr/local/bin
directory:
sudo tar xf gotestsum.tar.gz -C /usr/local/bin gotestsum
The gotestsum version can be checked in the following way:
gotestsum --version
Remove unneeded archive file:
rm -rf gotestsum.tar.gz
Testing gotestsum
For testing purpose, clone the repository and navigate to it:
git clone https://github.com/gotestyourself/gotestsum.git
cd gotestsum
The gotestsum provides various options. For example, the following command runs Go tests and generates a JUnit XML report in the specified file:
gotestsum --junitfile result.xml
Uninstall gotestsum
To uninstall gotestsum, delete the associated file:
sudo rm -rf /usr/local/bin/gotestsum
Leave a Comment
Cancel reply