test-framework-hunit 0.2.0 → 0.2.1
raw patch · 2 files changed
+23/−3 lines, 2 files
Files
Test/Framework/Providers/HUnit.hs view
@@ -1,15 +1,35 @@+-- | Allows HUnit test cases to be used with the test-framework package.+--+-- For an example of how to use test-framework, please see <http://github.com/batterseapower/test-framework/raw/master/example/Test/Framework/Example.lhs> module Test.Framework.Providers.HUnit (- testCase+ testCase,+ hUnitTestToTests, ) where import Test.Framework.Providers.API +import qualified Test.HUnit.Base import Test.HUnit.Lang -- | Create a 'Test' for a HUnit 'Assertion' testCase :: TestName -> Assertion -> Test testCase name = Test name . TestCase++-- | Adapt an existing HUnit test into a list of test-framework tests.+-- This is useful when migrating your existing HUnit test suite to test-framework.+hUnitTestToTests :: Test.HUnit.Base.Test -> [Test]+hUnitTestToTests = go ""+ where+ go desc (Test.HUnit.Base.TestCase a) = [testCase desc a]+ go desc (Test.HUnit.Base.TestLabel s t) = go (desc ++ ":" ++ s) t+ go desc (Test.HUnit.Base.TestList ts)+ -- If the list occurs at the top level (with no description above it),+ -- just return that list straightforwardly+ | null desc = concatMap (go desc) ts+ -- If the list occurs with a description, turn that into a honest-to-god+ -- test group. This is heuristic, but likely to give good results+ | otherwise = [testGroup desc (concatMap (go "") ts)] instance TestResultlike TestCaseRunning TestCaseResult where
test-framework-hunit.cabal view
@@ -1,6 +1,6 @@ Name: test-framework-hunit-Version: 0.2.0-Cabal-Version: >= 1.2+Version: 0.2.1+Cabal-Version: >= 1.2.3 Category: Testing Synopsis: HUnit support for the test-framework package. License: BSD3