exectest

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: MIT Imports: 8 Imported by: 0

README

exectest - Declarative CLI testing

You need to test plain-old-cli application with integration tests! That's it!

Build you binary and run in with the tool:

exectest.Execute(t, "ls", `
This is an arbitrary test description.
--file:a.txt
--file:.b.txt
--stdout
a.txt
`)

Or you might call it for the file path to the description using ExecuteForFile function.

Check out the docs for more info. See the tests for examples. The real-usage example you might find in monotask.

Documentation

Overview

Package exectest is os/exec package testing facilities.

The main goal of the package: declarative testing of any executable..

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(t *testing.T, binary, scheme string, opts ...cmdOption)

Execute is the main testing facility of the package.

Function consists of the steps:

  • [prepareScheme]: create directory, parse args and required stdout.
  • execute given binary in the prepared conditions.
  • assert results of the binary evaluation.

Examples:

--file:a.txt
--file:.b.txt
--arg:-a
--stdout
.
..
.b.txt
a.txt

This is a desciption of the command `ls -a` run in the directory with a.txt and .b.txt files.

func ExecuteForFile

func ExecuteForFile(t *testing.T, binary string, file string, opts ...cmdOption)

ExecuteForFile the same as the Execute but uses a file (path) with a scheme.

Types

This section is empty.

Jump to

Keyboard shortcuts

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