所以我试图遵循Haskell项目的建议结构,并且我在组织测试时遇到了一些问题.
为简单起见,让我们从:
src/Clue/Cards.hs # defines Clue.Cards module
testsuite/tests/Clue/Cards.hs # tests Clue.Cards module
Run Code Online (Sandbox Code Playgroud)
首先,我不知道testsuite/tests/Clue/Cards.hs该包含测试代码的模块名称是什么,而另一方面,我不知道如何编译我的测试代码以便我可以链接到我的源代码:
% ghc -c testsuite/tests/Clue/Cards.hs -L src
testsuite/tests/Clue/Cards.hs:5:0:
Failed to load interface for `Clue.Cards':
Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)
hvr*_*hvr 26
我自己使用Snap Framework为他们的测试套件采用的方法,它基本归结为:
通过附加.Tests到包含IUT的module-name来命名包含测试的模块,例如:
module Clue.Cards where ... -- module containing IUT
module Clue.Cards.Tests where ... -- module containing tests for IUT
Run Code Online (Sandbox Code Playgroud)通过使用单独的命名空间,您可以将测试放在单独的源文件夹中tests/,然后可以使用单独的Cabal构建目标(另请参阅cabal test最近的Cabal版本中的-build-target支持)用于测试套件,其中包含其他源代码文件夹在其hs-source-dirs设置中,例如:
Executable clue
hs-source-dirs: src
...
Executable clue-testsuite
hs-source-dirs: src tests
...
Run Code Online (Sandbox Code Playgroud)
这是有效的,因为IUT和测试套件中的模块之间不存在命名空间冲突.
| 归档时间: |
|
| 查看次数: |
2759 次 |
| 最近记录: |