21
votes

I created a very simple project with stack. It contains: an executable, a library and test targets in the associated cabal file. When I load the code to ghci via stack ghci, I can't access test there, even if they are in separate module. Is there any way to use it in such a way?

1

1 Answers

25
votes

Try stack ghci (your project name):(the test suite name). Then you should be able to enter main and your tests will run.

Example:

If your .cabal project file had the following values:

name: ExampleProject
...
test-suite Example-test

Then the command to run would be stack ghci ExampleProject:Example-test

(edit suggested by @Chris Stryczynski)

To watch the test and src directories so they are updated when you reload with :r, run:

stack ghci --ghci-options -isrc --ghci-options -itest ExampleProduct:Example-test