[Haskell-cafe] Replacing IO with pure values

Corentin Dupont corentin.dupont at gmail.com
Mon Nov 24 16:26:24 UTC 2014


This Stackoverflow give a lot of hints:
http://stackoverflow.com/questions/7370073/testing-functions-in-haskell-that-do-io

You cannot "Unit" test functions that performs IO, because by definition a
unit test is about testing an isolated piece of code that give the same
result for the same input, i.e. pure.
In my programs I separate the non-IO parts for the IO parts, so that I can
test the non-IO parts.
The IO parts are mainly the GUI parts of my apps, which I test manually.

Now it should be possible to trick the IO monad by supplying always the
same user input to your function, but I don't know how to do that.t
performs, because by definition a unit test is about testing an isolated
piece of code that give the same result for the same input, i.e. pure.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141124/a106dd3f/attachment.html>


More information about the Haskell-Cafe mailing list