Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

io.github.libtmux.junit5.FakeTmux.FakeTmux

Java
  • Python Unavailable
  • Ruby Unavailable
  • Lua Unavailable
  • TypeScript Unavailable
  • Rust Unavailable
  • Go Unavailable
  • Java
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

View as Markdown

Module
io.github.libtmux.junit5.FakeTmux
Package
io.github.libtmux:libtmux
Source
libtmux-junit5/src/main/java/io/github/libtmux/junit5/FakeTmux.java
class io.github.libtmux.junit5.FakeTmux.FakeTmux
classreadonly [source]
classreadonly [source]
class io.github.libtmux.junit5.FakeTmux.FakeTmux

A tmux server that is not there, for testing code that uses this library without starting one.

It answers the way tmux answers, not the way a stub would: a listing is rendered from the template the library sends, so a snapshot of a fake server is a real snapshot and every handle works; a handle command is fenced on the server's identity and refused once the fake is replaced, as tmux refuses it; a group stops at its first failure. What it models is the hierarchy — sessions, windows, panes and their names and titles — and what each pane shows. What it does not model is a shell: keys sent to a pane are recorded, not run, and a pane shows what the test says.

For behaviour that depends on tmux itself — what a release does with a flag, how a real shell echoes — test against real tmux with TmuxExtension instead. This is for code whose interest in tmux ends at the calls it makes.

Examples

FakeTmux tmux = new FakeTmux();
PaneId editor = tmux.addSession("work");
tmux.show(editor, "$ make", "make: Nothing to be done for 'all'.");
try (Server server = tmux.server()) {
Pane pane = server.pane(editor).orElseThrow();
pane.capture(); // → [$ make, make: Nothing to be done for 'all'.]
pane.sendLine("make test");
}
tmux.sent(); // every command, as the library sent it

11 declared, 0 inherited

Members

  • sessions method The sessions the fake holds now, by id.
  • addSession method Adds a session with one window and one pane running sh, as new-session makes.
  • close method
  • execute method
  • FakeTmux method A fake server with no sessions, as tmux is before anything has been created.
  • Formats class The part of tmux's format language the library sends: variables, == and &&.
  • Groups class Reads a command group the way tmux's command parser reads it: words in single quotes, a quote spelled '\'', a line break spelled "\n", commands separated by ;.
  • restart method Replaces the server, as a restart does: a new process, and nothing in it.
  • sent method Every command the library sent, in order, each as the words tmux would have read.
  • server method A server this transport answers for.
  • show method What the pane shows, one element per line, which is what capturing it answers.
Esc

Type to search.