mercredi 25 mai 2016

Importing modules for testing

I'm having some trouble importing a module for testing. I want to import Load in TestLoad in order to test it. I've tried adding the source directory to hs-source-dirs and both the package nsga and the module Load to build-depends in the cabal file for the testing package, but GHC still complains Could not find module Load when I attempt to import Load in TestLoad.hs.

I'm also curious about how to structure the tests and how to name the files. Is the approach below correct?

Directory structure:

nsga/
    src/
        Main.hs
        Load.hs
    test/
        TestMain.hs
        TestLoad.hs

The cabal file:

executable nsga
    main-is: Main.hs
    build-depends:
        QuickCheck -any,
        base -any,
        doctest -any
    default-language: Haskell2010
    hs-source-dirs: src
    other-modules:
        Load
    ghc-options: -ferror-spans -Wall -fsimpl-tick-factor=10

test-suite test-nsga
    type: exitcode-stdio-1.0
    main-is: TestMain.hs
    build-depends:
        QuickCheck -any,
        base -any,
        doctest -any,
        HUnit -any,
        nsga -any,
        Load -any
    default-language: Haskell2010
    hs-source-dirs: test, src
    other-modules:
        TestLoad
    ghc-options: -ferror-spans

Aucun commentaire:

Enregistrer un commentaire