| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Hls
Synopsis
- module Test.Tasty.HUnit
- withResource :: IO a -> (a -> IO ()) -> (IO a -> TestTree) -> TestTree
- askOption :: IsOption v => (v -> TestTree) -> TestTree
- localOption :: IsOption v => v -> TestTree -> TestTree
- adjustOption :: IsOption v => (v -> v) -> TestTree -> TestTree
- defaultMain :: TestTree -> IO ()
- defaultIngredients :: [Ingredient]
- defaultMainWithIngredients :: [Ingredient] -> TestTree -> IO ()
- includingOptions :: [OptionDescription] -> Ingredient
- after :: DependencyType -> String -> TestTree -> TestTree
- after_ :: DependencyType -> Expr -> TestTree -> TestTree
- testGroup :: TestName -> [TestTree] -> TestTree
- type TestName = String
- data DependencyType
- data TestTree
- mkTimeout :: Integer -> Timeout
- pattern NoTimeout :: Timeout
- module Test.Tasty.ExpectedFailure
- module Test.Hls.Util
- module Language.LSP.Types
- module Language.LSP.Test
- module Control.Monad.IO.Class
- module Control.Applicative.Combinators
- defaultTestRunner :: TestTree -> IO ()
- goldenGitDiff :: TestName -> FilePath -> IO ByteString -> TestTree
- goldenWithHaskellDoc :: PluginDescriptor IdeState -> TestName -> FilePath -> FilePath -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
- goldenWithHaskellDocFormatter :: PluginDescriptor IdeState -> String -> TestName -> FilePath -> FilePath -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree
- def :: Default a => a
- runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a
- runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> FilePath -> Session a -> IO a
- runSessionWithServer' :: [PluginDescriptor IdeState] -> Config -> SessionConfig -> ClientCapabilities -> FilePath -> Session a -> IO a
- waitForProgressDone :: Session ()
- data PluginDescriptor ideState
- data IdeState
Documentation
module Test.Tasty.HUnit
Arguments
| :: IO a | initialize the resource |
| -> (a -> IO ()) | free the resource |
| -> (IO a -> TestTree) |
|
| -> TestTree |
Acquire the resource to run this test (sub)tree and release it afterwards
askOption :: IsOption v => (v -> TestTree) -> TestTree #
Customize the test tree based on the run-time options
localOption :: IsOption v => v -> TestTree -> TestTree #
Locally set the option value for the given test subtree
adjustOption :: IsOption v => (v -> v) -> TestTree -> TestTree #
Locally adjust the option value for the given test subtree
defaultMain :: TestTree -> IO () #
Parse the command line arguments and run the tests.
When the tests finish, this function calls exitWith with the exit code
that indicates whether any tests have failed. Most external systems
(stack, cabal, travis-ci, jenkins etc.) rely on the exit code to detect
whether the tests pass. If you want to do something else after
defaultMain returns, you need to catch the exception and then re-throw
it. Example:
import Test.Tasty
import Test.Tasty.HUnit
import System.Exit
import Control.Exception
test = testCase "Test 1" (2 @?= 3)
main = defaultMain test
`catch` (\e -> do
if e == ExitSuccess
then putStrLn "Yea"
else putStrLn "Nay"
throwIO e)defaultIngredients :: [Ingredient] #
List of the default ingredients. This is what defaultMain uses.
At the moment it consists of listingTests and consoleTestReporter.
defaultMainWithIngredients :: [Ingredient] -> TestTree -> IO () #
Parse the command line arguments and run the tests using the provided ingredient list.
When the tests finish, this function calls exitWith with the exit code
that indicates whether any tests have failed. See defaultMain for
details.
includingOptions :: [OptionDescription] -> Ingredient #
This ingredient doesn't do anything apart from registering additional options.
The option values can be accessed using askOption.
Arguments
| :: DependencyType | whether to run the tests even if some of the dependencies fail |
| -> String | the pattern |
| -> TestTree | the subtree that depends on other tests |
| -> TestTree | the subtree annotated with dependency information |
The after combinator declares dependencies between tests.
If a TestTree is wrapped in after, the tests in this tree will not run
until certain other tests («dependencies») have finished. These
dependencies are specified using an AWK pattern (see the «Patterns» section
in the README).
Moreover, if the DependencyType argument is set to AllSucceed and
at least one dependency has failed, this test tree will not run at all.
Tasty does not check that the pattern matches any tests (let alone the correct set of tests), so it is on you to supply the right pattern.
Examples
The following test will be executed only after all tests that contain
Foo anywhere in their path finish.
afterAllFinish"Foo" $testCase"A test that depends on Foo.Bar" $ ...
Note, however, that our test also happens to contain Foo as part of its name,
so it also matches the pattern and becomes a dependency of itself. This
will result in a DependencyLoop exception. To avoid this, either
change the test name so that it doesn't mention Foo or make the
pattern more specific.
You can use AWK patterns, for instance, to specify the full path to the dependency.
afterAllFinish"$0 == \"Tests.Foo.Bar\"" $testCase"A test that depends on Foo.Bar" $ ...
Or only specify the dependency's own name, ignoring the group names:
afterAllFinish"$NF == \"Bar\"" $testCase"A test that depends on Foo.Bar" $ ...
Since: tasty-1.2
Arguments
| :: DependencyType | whether to run the tests even if some of the dependencies fail |
| -> Expr | the pattern |
| -> TestTree | the subtree that depends on other tests |
| -> TestTree | the subtree annotated with dependency information |
Like after, but accepts the pattern as a syntax tree instead
of a string. Useful for generating a test tree programmatically.
Examples
Only match on the test's own name, ignoring the group names:
after_AllFinish(EQ(FieldNF) (StringLit"Bar")) $testCase"A test that depends on Foo.Bar" $ ...
Since: tasty-1.2
data DependencyType #
These are the two ways in which one test may depend on the others.
This is the same distinction as the hard vs soft dependencies in TestNG.
Since: tasty-1.2
Constructors
| AllSucceed | The current test tree will be executed after its dependencies finish, and only if all of the dependencies succeed. |
| AllFinish | The current test tree will be executed after its dependencies finish, regardless of whether they succeed or not. |
Instances
| Eq DependencyType | |
Defined in Test.Tasty.Core Methods (==) :: DependencyType -> DependencyType -> Bool # (/=) :: DependencyType -> DependencyType -> Bool # | |
| Show DependencyType | |
Defined in Test.Tasty.Core Methods showsPrec :: Int -> DependencyType -> ShowS # show :: DependencyType -> String # showList :: [DependencyType] -> ShowS # | |
The main data structure defining a test suite.
It consists of individual test cases and properties, organized in named groups which form a tree-like hierarchy.
There is no generic way to create a test case. Instead, every test
provider (tasty-hunit, tasty-smallcheck etc.) provides a function to
turn a test case into a TestTree.
Groups can be created using testGroup.
module Test.Tasty.ExpectedFailure
module Test.Hls.Util
module Language.LSP.Types
module Language.LSP.Test
module Control.Monad.IO.Class
defaultTestRunner :: TestTree -> IO () Source #
Run defaultMainWithRerun, limiting each single test case running at most 10 minutes
goldenGitDiff :: TestName -> FilePath -> IO ByteString -> TestTree Source #
goldenWithHaskellDoc :: PluginDescriptor IdeState -> TestName -> FilePath -> FilePath -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree Source #
goldenWithHaskellDocFormatter :: PluginDescriptor IdeState -> String -> TestName -> FilePath -> FilePath -> FilePath -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree Source #
runSessionWithServer :: PluginDescriptor IdeState -> FilePath -> Session a -> IO a Source #
runSessionWithServerFormatter :: PluginDescriptor IdeState -> String -> FilePath -> Session a -> IO a Source #
runSessionWithServer' Source #
Arguments
| :: [PluginDescriptor IdeState] | plugins to load on the server |
| -> Config | lsp config for the server |
| -> SessionConfig | config for the test session |
| -> ClientCapabilities | |
| -> FilePath | |
| -> Session a | |
| -> IO a |
Host a server, and run a test session on it
Note: cwd will be shifted into root in Session a
waitForProgressDone :: Session () Source #
Wait for all progress to be done Needs at least one progress done notification to return
data PluginDescriptor ideState #