HTF has sample project which shows how to use test framework. Module MyPkg.A defines some tests and MyPkg.B defines some tests. Is it possible to write new module MyPkg.C which aggregates tests from modules A and B (and does not define new tests itself) ?
Instead of importing tests from A and B (in my test runner Main module), I want to import tests from single C module.
I implement MyPkg.C like this
{-# OPTIONS_GHC -F -pgmF htfpp #-}
module MyPkg.C (htf_importedTests) where
import Test.Framework
import {-@ HTF_TESTS @-} MyPkg.A
import {-@ HTF_TESTS @-} MyPkg.B
And my main test runner module like this:
{-# OPTIONS_GHC -F -pgmF htfpp #-}
module Main where
import Test.Framework
import Test.Framework.BlackBoxTest
import {-@ HTF_TESTS @-} MyPkg.C
main = htfMain htf_importedTests
When I try to compile this code, I get an error:
TestMain.hs:23:5:
Not in scope: `htf_MyPkg_C_thisModulesTests'
Perhaps you meant `htf_Main_thisModulesTests'
HTF doesn't seem to directly support this mode of operation. You can however achieve the goal with some hackery:
A.hs
B.hs
C.hs
TestMain.hs:
This works, but the problem is that we have to hardcode the module names in
C.hs
. I think a good idea would be to introduce a newdelegate_
test definition statement that allows you to delegate a test to anotherTestableHTF
, so that we can exporthtf_importedTests
as a single test. Maybe you can open a feature request for that or different solution to the problem.