4 ms·
How you would write tests in a real project? I suppose it's not writing out the entire program and then writing the tests, as seems to be implied. That would m
by danuker 4y ago
How you would write tests in a real project?
I suppose it's not writing out the entire program and then writing the tests, as seems to be implied. That would mean a lot of manual testing.
Or is there a Haskell REPL where you can try out small pieces before saving them?
- jose_zap 4y agoYes, there is GHCi, the Haskell interpreter and repl comes bundled with the compiler. You can load your entire project in the repl and try your functions there.
- rowanG077 4y agoYou have testing libraries in Haskell just like in every other languages. For example: https://hackage.haskell.org/package/tasty https://hackage.haskell.org/package/tasty
- gilmi 4y agoWhen you create a project description for your project (for the package manager) you can define a library, executables and test suites. In the test suite you write your tests against the library. You can do that at any stage, even before writing a line of library code. But yes, Haskell also has a REPL that can be used to experiment with code.
- jokethrowaway 4y agoHUnit is a popular choice: https://mmhaskell.com/testing/test-driven-development https://mmhaskell.com/testing/test-driven-development
- lgas 4y agoIn addition to the other good answers you've gotten, I would like to point out that Haskell has QuickCheck (https://hackage.haskell.org/package/QuickCheck https://hackage.haskell.org/package/QuickCheck) which, if I'm not mistaken, more or less pioneered property testing. Property testing libraries are available in many languages now but they never seem to be as capture the magic of QuickCheck. (There's also https://hackage.haskell.org/package/hedgehog https://hackage.haskell.org/package/hedgehog which is sort of a "modern alternative" to QuickCheck but I still prefer the OG).