我想使用test-framework-th来生成测试组。
我有这个主要测试模块:
module Main where
import Test.Framework.TH
import Foo.Test
main = $(defaultMainGenerator)
此模块包含测试:
module Foo.Test where
import Test.HUnit
case_1 = do 1 @=? 2
但是,defaultMainGenerator
未检测到Foo.Test
模块中的测试。它仅检测调用它的模块中的测试(在本例中为Main
)。
如何在不重复模板的情况下跨模块拆分我的测试?
答案 0 :(得分:0)
在每个模块中使用testGroupGenerator
为该模块生成测试组,然后使用main
中的测试组,例如
Foo.hs:
module Foo where
import Test.Framework.TH
tests = $(testGroupGenerator)
...
Bar.hs:
module Bar where
import Test.Framework.TH
tests = $(testGroupGenerator)
...
Main.hs:
import Test.Framework
import Foo
import Bar
main = defaultMain [Foo.tests, Bar.tests]