Description
An automatable terminal session with send/expect controls.
This package leverages the
go-expect package to test
terminal applications on Linux, MacOS and Windows, which has been forked from
Netflix/go-expect
It has been developed for CI testing of the ActiveState state
tool
termtest alternatives and similar packages
Based on the "Command Line" category.
Alternatively, view termtest alternatives based on common mentions on social networks and blogs.
-
urfave/cli
A simple, fast, and fun package for building command line apps in Go -
Rich Interactive Widgets for Terminal UIs
Terminal UI library with rich, interactive widgets — written in Golang -
elvish
Elvish = Expressive Programming Language + Versatile Interactive Shell -
go-prompt
Building powerful interactive prompts in Go, inspired by python-prompt-toolkit. -
tcell
Tcell is an alternate terminal package, similar in some ways to termbox, but better in others. -
survey
A golang library for building interactive and accessible prompts with full support for windows and posix terminals. -
cointop
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀 -
pterm
✨ #PTerm is a modern Go module to easily beautify console output. Featuring charts, progressbars, tables, trees, text input, select menus and much more 🚀 It's completely configurable and 100% cross-platform compatible. -
progressbar
A really basic thread-safe progress bar for Golang applications -
The Platinum Searcher
A code search tool similar to ack and the_silver_searcher(ag). It supports multi platforms and multi encodings. -
pflag
Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. -
readline
Readline is a pure go(golang) implementation for GNU-Readline kind library -
asciigraph
Go package to make lightweight ASCII line graph ╭┈╯ in command line apps with no other dependencies. -
uiprogress
A go library to render progress bars in terminal applications -
Git Town
Git workflow automation to keep branches in sync and reduce merge conflicts. -
dotenv-linter
⚡️Lightning-fast linter for .env files. Written in Rust 🦀 -
mitchellh/cli
A Go library for implementing command-line interfaces. -
termenv
Advanced ANSI style & color support for your terminal applications -
CLI Color
🎨 Terminal color rendering library, support 8/16 colors, 256 colors, RGB color rendering output, support Print/Sprintf methods, compatible with Windows. GO CLI 控制台颜色渲染工具库,支持16色,256色,RGB色彩渲染输出,使用类似于 Print/Sprintf,兼容并支持 Windows 环境的色彩渲染 -
ov
🎑Feature-rich terminal-based text viewer. It is a so-called terminal pager. -
complete
bash completion written in go + bash completion for go command -
flaggy
Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies. -
uitable
A go library to improve readability in terminal apps using tabular data
Tired of breaking your main and manually rebasing outdated pull requests?
Do you think we are missing an alternative of termtest or a related project?
Popular Comparisons
README
termtest
An automatable terminal session with send/expect controls.
This package leverages the go-expect package to test terminal applications on Linux, MacOS and Windows, which has been forked from Netflix/go-expect
It has been developed for CI testing of the ActiveState state tool
Example usage
import (
"testing"
"github.com/ActiveState/termtest"
"github.com/stretchr/testify/suite"
)
func TestBash(t *testing.T) {
opts := termtest.Options{
CmdName: "/bin/bash",
}
cp, err := termtest.NewTest(t, opts)
require.NoError(t, err, "create console process")
defer cp.Close()
cp.SendLine("echo hello world")
cp.Expect("hello world")
cp.SendLine("exit")
cp.ExpectExitCode(0)
}
Multi-line matching
After each bytes termtest
receives from the pseudo-terminal output, it updates the state of the virtual terminal like a terminal user would see it (including a scroll back buffer if necessary). The Expect()
look for matches in this processed output. Of course, the terminal wraps its output after text gets longer than 80 columns (or whatever width you have configured for your terminal). As this makes it more difficult to match long string, the default Expect()
removes all these automatic wraps.
Consider the following examples, that all assume a terminal width of 10 columns.
Programme sends a line with more than 10 characters
- Programme sends string "0123456789012345".
- Terminal output is "0123456789\n012345 \n".
cp.Expect("0123456789012345") // this matches
Programme sends several lines separated by \n
- Programme sends string "line 1\nline 2\n".
- Terminal output is "line 1 \nline 2 \n".
- The following does NOT match:
cp.Expect("line 1\nline 2\n") // this does NOT match
- The following does MATCH:
cp.Expect("line 1") cp.Expect("line 2")
- The following does MATCH:
cp.Expect("line 1 line 2 ")
Custom matchers
Custom matchers that match against either the raw / or processed pseudo-terminal output can be specified in the go-expect
package. See expect_opt.go
for examples.