Two new libraries to extend tasty testing framework

When I recently wrote about porting my haskell-testing-stub project to tasty I mentioned that test-framework still has more libraries than tasty. I decided to contribute to changing that and released two small packages that extend tasty with extra functionality:

  • tasty-hunit-adapter allows to import existing HUnit tests into tasty (hackage, github):
    module Main where
     
    import Test.HUnit               ( (~:), (@=?)            )
    import Test.Tasty               ( defaultMain, testGroup )
    import Test.Tasty.HUnit.Adapter ( hUnitTestToTestTree    )
     
    main :: IO ()
    main = defaultMain $ testGroup "Migrated from HUnit" $
           hUnitTestToTestTree ("HUnit test" ~: 2 + 2 @=? 4)
  • tasty-program allows to run external program and test whether it terminates successfully (hackage, github):
    module Main (
      main
     ) where
     
    import Test.Tasty
    import Test.Tasty.Program
     
    main :: IO ()
    main = defaultMain $ testGroup "Compilation with GHC" $ [
        testProgram "Foo" "ghc" ["-fforce-recomp", "foo.hs"] 
                    Nothing
      ]
  • This package has only this basic functionality at the moment. A missing feature is the possibility of logging stdout and stderr to a file so that it can later be inspected or perhaps used by a golden test (but for the latter tasty needs test dependencies).

Leave a Reply

(required)

Staypressed theme by Themocracy