Testing
In this chapter we will discuss various ways how to test command line tools.
Unit Tests
Unit tests are highly language and framework specific, therefore we will discuss most of the specific(s) within the language specific subsections.
Python
General structure for testable python cli’s
TBD
Mocking stdin, stdout, stderr
TBD
Make sure argv cann be passed
TBD
How to check exit code
TBD
Rust
TBD
Integration Tests
What should you be checking
Return Code(s)
output -> stdout
Maybe stderr
output files
Signal(s) & Signal handling
Making your CLI testable
timeouts
count’s
return code
output stdout/stderr
input stdin
input output format(s)
Shell Scripts
diff
shell scripts
Cram
Creating input files
- Making sure tests fail
count
poll
timeout
Checking return codes
checking stdout
checking stderr
- quirks
indention
blocking
cleanup
Cram Advanced
- Common Fixtures Shell scripts
let it fail
Specdown
Socat
e.g. connecting client + server impl and verify exit’s
Tshark
TBD
Curl
TBD
Diff
TBD
Examples
Testing GraphQl Endpoint
Testing RestEndpoint
Testing Protocol Dissector