- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 stackproject stapro
,其中包含一个文件 app/Main.hs
module Main where
import Lib
main = putStrLn "This is main"
foo::Int ->Int
foo = (+1)
和一个文件test/Spec.hs
module Spec where
import Test.HUnit
import Main (foo)
main :: IO ()
main = putStrLn "Test suite not yet implemented"
testFoo :: Test
testFoo = TestCase $ assertEqual "Should return 2" 2 (foo 1)
当我尝试执行测试时
$ stack test
While constructing the BuildPlan the following exceptions were encountered:
-- While attempting to add dependency,
Could not find package Main in known packages
-- Failure when adding dependencies:
Main: needed (-any), stack configuration has no specified version
needed for package stapro-0.1.0.0
我的 .cabal 文件是
name: stapro
version: 0.1.0.0
...
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Lib
build-depends: base >= 4.7 && < 5
default-language: Haskell2010
executable stapro-exe
hs-source-dirs: app
main-is: Main.hs
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends: base
, stapro
default-language: Haskell2010
test-suite stapro-test
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Spec.hs
build-depends: base
, stapro
, HUnit
, Main
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010
...
最佳答案
看起来您正在尝试依赖可执行文件(test-suite
部分的 build-depends
中的 Main
),这样您就可以在您的测试套件中对其进行测试。这是行不通的,事实上你根本无法真正测试你的可执行文件。
从build-depends
中删除Main
。将您想要测试的所有代码移至您的库中。
关于haskell - 如何在堆栈中使用HUnit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39459542/
我有一个全新的堆栈和 ghci 安装: $ stack --version Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b06
我正在尝试在 Haskell 中进行一些单元测试,这基本上是我在代码中所做的: module Test where import Test.HUnit test = TestList [TestLab
如果我有一个导致某个输入错误的函数,是否可以编写一个测试来验证该输入是否发生错误? 我在 HUnit 中找不到这个“断言错误”功能。 .它是否在 HUnit 或其他一些测试包中可用? 最佳答案 您可以
是否有任何 HUnit 或 QuickCheck 扩展允许像 Bamboo 这样的持续集成系统?做详细的测试结果报告? 到目前为止,我最好的想法是简单地触发测试作为构建脚本的一部分,并依靠测试以非零退
我写了一个类似LISP的flatten的函数: data NestedList a = Elem a | List [NestedList a] flatten :: NestedList a ->
我在使用 Test-Framework 和 HUnit 设置单元测试时遇到问题。 我的测试文件中有以下导入: import Test.Framework import Test.Framework.P
我刚刚安装了 HUnit,并想将其导入 ghci。 Prelude> import HUnit : Could not find module `HUnit': Use -v to
在全新安装的 Haskell Platform for Max OSX 上,当使用 runghc 解释器运行时,以下代码在 import Test.HUnit 上失败。 {-- - Save thi
我有一个功能: unify :: [Constraint] -> [Substitution] 并且在某些情况下它会抛出异常 error功能: error "Circular constraint"
类似于quickcheck如何支持反例: property \x -> counterexample ("Foo failed with: " ++ ...) $ foo x 但在某种程度
我是 Yesod 的初学者,对 Cablal 没有经验 - 我使用脚手架工具初始化一个新的 Yesod 项目,编写了一些处理程序和其他代码,现在我正在努力添加一些 HUnit 测试 - 如何在一个最好
所以我尝试使用 HTF 来运行一些 HUnit 风格的断言 % cat tests/TestDemo.hs {-# OPTIONS_GHC -Wall -F -pgmF htfpp #-} modul
我是 Haskell 的新手,如果我的术语不太正确,请提前致歉。 我想为一个非常简单的项目实现一些简单的单元测试,通过 cabal 管理。我注意到 this very similar question
一天的大部分时间里,我一直在与 Cabal 进行斗争,试图让它的自动化测试功能与 HUnit 一起工作。我已阅读文档 here和 here ,并且我已经设置了我的测试套件部分,就像它显示的那样,但是每
我正在尝试在 Test.Tasty testGroup 中运行多个测试(即多个断言);但输入已从 IO 读取的单个“对象”。 例如,我读取并解析一个文件;我想针对该文件的结果做出多个断言。类似的东西
如果我有 test/Test.hs和 module Main where import Test.HUnit test1 :: Test test1 = TestCase $ assertEqual
我目前有以下测试代码: testUpdate :: Test testUpdate = testCase "update does change artist" $ do (created, Ju
HUnit 有某种方法可以实现近似相等吗?显然,这失败了: test1 = TestCase (assertEqual "Should equal" (get_scores) [(0.3, 0.3),
我通过堆栈测试使用HUnit-Plus,我相信它使用了Distribution.TestSuite。 当我遇到编译错误时,我会在错误中得到文件路径和行号。这很棒,因为我只需单击编辑器中的错误并直接跳转
我是一名优秀的程序员,十分优秀!