main-tester: Capture stdout/stderr/exit code, and replace stdin of your main function.

[ apache, library, system, testing ] [ Propose Tags ]

See README.md for detail.


[Skip to Readme]

Flags

Manual Flags

NameDescriptionDefault
doctest

Build and run doctest. Turn off to avoid error on some environment.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.2.0.0, 0.2.0.1
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), bytestring, directory [details]
License Apache-2.0
Copyright 2018 Yuji Yamamoto
Author Yuji Yamamoto
Maintainer whosekiteneverfly@gmail.com
Category System, Testing
Home page https://gitlab.com/igrep/main-tester#readme
Source repo head: git clone https://gitlab.com/igrep/main-tester
Uploaded by igrep at 2018-09-24T17:11:03Z
Distributions LTSHaskell:0.2.0.1, NixOS:0.2.0.1, Stackage:0.2.0.1
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3723 total (33 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-09-24 [all 1 reports]

Readme for main-tester-0.2.0.0

[back to package description]

main-tester

Capture stdout/stderr/exit code, and replace stdin of your main function.

Why?

Against the best practice, I often prefer large, end-to-end (E2E) tests.
Because:

  • E2E tests can directly test your users' requirement.
  • E2E tests can detect bugs caused by misassumption of external components
    • Which happenes relatively more often than the others, according to my experience.
  • I often write small programs where E2E tests are sufficient.

This library main-tester provides utility functions for E2E testing of your CLI applications.
With main-tester, You can test your apps with arbitrary stdin data, check their output and exit code.

Comparison with silently and System.IO.Fake

  • Can test exit code of your main.
  • All input and outputs are strict bytestrings except the command line arguments, which is very important when testing with non-UTF8 input and output.
  • Currently doesn't support suppressing stdout and stderr (Pull request welcome!).

Usage

See the document of Test.Main module.