Namespace cli4clj.cli-tests

Helper functions for testing CLIs.

Other Namespaces

Show/Hide
cli4clj.cli
cli4clj allows to create simple interactive command line interfaces for Clojure applications.
cli4clj.example
This is a simple example for using cli4clj. The example can be run via "lein run".
Index Page
Alphabetic Var Index

Public Vars

Usage Documentation

Show/Hide
Helper functions for testing CLIs.
Back to top

Details of Public Vars

Function: cmd-vector-to-test-input-string

Arglists:
=========

  (cmd-vector-to-test-input-string cmd-vec)

Docstring:
==========

  This function takes a vector of string commands and creates a one-line command that is suited to being passed to a cli instance during testing.
Back to top View Source

Function: create-repl-read-test-fn

Arglists:
=========

  (create-repl-read-test-fn opts)

Docstring:
==========

  This function creates a repl read function for testing.
Back to top View Source

Function: exec-tested-fn

Arglists:
=========

  (exec-tested-fn tested-fn)

Docstring:
==========

  This function takes another function as argument and executes it in a way that is suited for testing.
Back to top View Source

Function: expected-string

Arglists:
=========

  (expected-string expected-lines)
  (expected-string expected-lines separator)

Docstring:
==========

  Takes a vector of strings that are intended to represent individual lines of expected command line output and converts them into a string that can be compared against the output of the test-cli-stdout and test-cli-stderr functions.
   The most notably property is that the lines are joined based on the platform dependent line.separator.
Back to top View Source

Function: string-latch

Arglists:
=========

  (string-latch sl-defs)

Docstring:
==========

  A string-latch can be used for testing CLI UI interaction with multi-threaded behaviour.

   The latch takes a vector of string-latch definitions (sl-defs).
   Each string-latch definition defines a "wait" point, which will block the execution of the main CLI UI test thread until the string-latch definition was matched in the CLI output.
   When multiple string-latch definitions are configured in the vector, the definitions have to be matched in the CLI output in the order in which they are defined in the sl-defs vector.
  
   A string-latch definition can either be a string or a two element vector of a string and a function.
   When only a string is used, the latch will simply await the occurrence of the string in the CLI output.
   When the two element vector is used, the latch will wait for the occurrence of the string and will call the function once the string was matched.
   Both representations, string and string plus function vector, can be mixed in the overall string-latch definitions vector.
Back to top View Source

Function: test-cli-stderr

Arglists:
=========

  (test-cli-stderr tested-fn in-cmds)
  (test-cli-stderr tested-fn in-cmds sl)

Docstring:
==========

  Takes a function to be tested and a vector of string input commands and returns the string that was printed to stderr as a result of executing the supplied commands in the cli provided by the tested-fn.
  
   If an optional string-latch is supplied, the call will block until the string-latch completed.
Back to top View Source

Function: test-cli-stderr-cb

Arglists:
=========

  (test-cli-stderr-cb tested-fn in-cmds cb-fn)

Docstring:
==========

  Takes a function to be tested and a vector of string input commands and returns the string that was printed to stdout as a result of executing the supplied commands in the cli provided by the tested-fn.
   In addition the function cb-fn will be called for each element that is written to stderr.
Back to top View Source

Function: test-cli-stdout

Arglists:
=========

  (test-cli-stdout tested-fn in-cmds)
  (test-cli-stdout tested-fn in-cmds sl)

Docstring:
==========

  Takes a function to be tested and a vector of string input commands and returns the string that was printed to stdout as a result of executing the supplied commands in the cli provided by the tested-fn.
  
   If an optional string-latch is supplied, the call will block until the string-latch completed.
Back to top View Source

Function: test-cli-stdout-cb

Arglists:
=========

  (test-cli-stdout-cb tested-fn in-cmds cb-fn)

Docstring:
==========

  Takes a function to be tested and a vector of string input commands and returns the string that was printed to stdout as a result of executing the supplied commands in the cli provided by the tested-fn.
   In addition the function cb-fn will be called for each element that is written to stdout.
Back to top View Source