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

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

See for detail.

[Skip to Readme]


Manual Flags


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


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


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS],,
Change log
Dependencies base (>=4.7 && <5), bytestring, directory [details]
License Apache-2.0
Copyright 2018 Yuji Yamamoto
Author Yuji Yamamoto
Category System, Testing
Home page
Source repo head: git clone
Uploaded by igrep at 2019-03-19T08:57:27Z
Distributions LTSHaskell:, NixOS:, Stackage:
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 3612 total (30 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 2019-03-19 [all 1 reports]

Readme for main-tester-

[back to package description]


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


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

  • 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!).


See the document of Test.Main module.