@@ -7,9 +7,15 @@ import Data.Aeson
77import Data.List (isSuffixOf)
88import Data.Monoid
99import System.Directory (getDirectoryContents)
10−import Test.Tasty (defaultMain, testGroup)
10+import Test.Tasty (TestTree, defaultMain, testGroup)
11+import qualified Test.Tasty.HUnit as HU
1112import Test.Tasty.QuickCheck (testProperty)
1213
14+-- Examples
15+import qualified CustomSchema as C
16+import qualified PrettyShowFailure as P
17+import qualified Standard as S
18+
1319import Data.JsonSchema.Draft4
1420import Local.Failure (correctPaths)
1521import Local.Filesystem (fetchFromFilesystem)
@@ -24,11 +30,23 @@ main = do
2430 filenames <- filter isLocal . filter (".json" `isSuffixOf`) <$> getDirectoryContents dir
2531 ts <- readSchemaTests dir filenames
2632 defaultMain . testGroup "Tests not requiring an HTTP server" $
27− testProperty "Invert schemas through JSON without change" invertSchema
33+ testGroup "Check that examples compile" exampleTests
34+ : testGroup "QuickCheck tests" quickCheckTests
2835 : testGroup "Report the path to invalid data correctly" correctPaths
2936 : testGroup "Test the referencesViaFilesystem function" fetchFromFilesystem
3037 : testGroup "Test the Reference module" referenceTests
3138 : fmap toTest ts
3239
33−invertSchema :: Schema -> Bool
34−invertSchema a = Just a == decode (encode a)
40+quickCheckTests :: [TestTree]
41+quickCheckTests =
42+ [testProperty "Invert schemas through JSON without change" invertSchema]
43+ where
44+ invertSchema :: Schema -> Bool
45+ invertSchema a = Just a == decode (encode a)
46+
47+exampleTests :: [TestTree]
48+exampleTests =
49+ [ HU.testCase "Standard Example" S.example
50+ , HU.testCase "PrettyShowFailure Example" P.example
51+ , HU.testCase "CustomSchema Example" C.example
52+ ]