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]
Versions [faq] 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 Tue Mar 19 08:57:27 UTC 2019
Distributions LTSHaskell:0.2.0.1, NixOS:0.2.0.1, Stackage:0.2.0.1
Downloads 520 total (65 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2019-03-19 [all 1 reports]

Modules

[Index] [Quick Jump]

Flags

NameDescriptionDefaultType
doctest

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

DisabledManual

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

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for main-tester-0.2.0.1

[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.