toolsetup:testframework
Table of Contents
Test framework setup
Preconditions / configuration
- Installations:
- resolver: lts-17.5
- Haskel project has been setup with stack
stack new <ProjectName>
Steps
All to to be reworked for Test.Tasty.
- Adapt package.yaml by adding the packages “tasty”, …, and so on as dependencies below section “tests”, as in the code shown below.
- code below
tests:, and<ProjectName>-test::dependencies: - <ProjectName> - <FurtherPackagesToUse>
- complete file of package.yaml
name: <ProjectNAme> version: ... github: ... license: ... author: ... maintainer: ... copyright: ... extra-source-files: - ... ... description: Please see the README on GitHub at <https://github.com/githubuser/Test1#readme> dependencies: - base >= 4.7 && < 5 library: source-dirs: src executables: ... tests: <ProjectName>-test: main: Spec.hs source-dirs: test ghc-options: - -threaded - -rtsopts - -with-rtsopts=-N dependencies: - <ProjectName> - <FurterPackagesNeededForTests>
- On windows setups, in order to avoid problems with regex (see https://github.com/haskell-hvr/regex-posix/issues/4), we have to adapt the file stack.yaml.
- Add lib “regex-posix-clib-2.7” into section extra-deps.
- Add flag “_regex-posix-clib: true” and “regex-posix:” below section flags
# This file was automatically generated by 'stack init' # # Some commonly used options have been documented as comments in this file. ... resolver: ... # User packages to be built. ... packages: - . ... extra-deps: - regex-posix-clib-2.7 # Override default flag values for local packages and extra-deps flags: regex-posix: _regex-posix-clib: true ... # compiler-check: newer-minor
- Implement the test in file “Spec.hs” that is below folder “test” of the project by importing the 5 packages “Test.Framework”, and so on as shown in the code below.
-- to be adapted for using tasty import ... import qualified Lib as Lib main :: IO () main = ... ...
- Run
stack testand it will build your tests and run the tests...
✎
You could leave a comment if you were logged in.
toolsetup/testframework.txt · Last modified: by 127.0.0.1
