User Tools

Site Tools


toolsetup:testframework

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
toolsetup:testframework [2021/03/20 18:58] – [Steps] f2b216toolsetup:testframework [2025/10/08 00:48] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== Test framework setup ====== ====== Test framework setup ======
- 
----- 
  
 ===== Preconditions / configuration ===== ===== Preconditions / configuration =====
Line 13: Line 11:
 ===== Steps ===== ===== Steps =====
  
-  - Adapt **__package.yaml__** by adding the packages "test-framework", "test-framework-hunit", and so on as dependencies below section "tests", as in the code shown below.+<WRAP center round important 60%> 
 +All to to be reworked for [[https://hackage.haskell.org/package/tasty|Test.Tasty]]. 
 +</WRAP> 
 + 
 +  - Adapt **__package.yaml__** by adding the packages "tasty", ..., and so on as dependencies below section "tests", as in the code shown below.
     * code below ''tests:'', and ''<ProjectName>-test:'':     * code below ''tests:'', and ''<ProjectName>-test:'':
       * <code>       * <code>
     dependencies:     dependencies:
     - <ProjectName>     - <ProjectName>
-    - test-framework +    - <FurtherPackagesToUse>
-    - test-framework-hunit +
-    - test-framework-quickcheck2 +
-    - HUnit +
-    - QuickCheck+
 </code> </code>
     * complete file of package.yaml     * complete file of package.yaml
Line 60: Line 58:
     dependencies:     dependencies:
     - <ProjectName>     - <ProjectName>
-    - test-framework +    - <FurterPackagesNeededForTests>
-    - test-framework-hunit +
-    - test-framework-quickcheck2 +
-    - HUnit +
-    - QuickCheck+
 </code> </code>
   - On windows setups, in order to avoid problems with regex (see https://github.com/haskell-hvr/regex-posix/issues/4), we have to adapt the file stack.yaml.   - On windows setups, in order to avoid problems with regex (see https://github.com/haskell-hvr/regex-posix/issues/4), we have to adapt the file stack.yaml.
Line 101: Line 95:
   - Implement the test in file "Spec.hs" that is below folder "test" of the project by importing the 5 packages "Test.Framework", and so on as shown in the code below.   - Implement the test in file "Spec.hs" that is below folder "test" of the project by importing the 5 packages "Test.Framework", and so on as shown in the code below.
     * <code>     * <code>
-import Test.Framework +-- to be adapted for using tasty 
-import Test.Framework.Providers.HUnit +import ...
-import Test.Framework.Providers.QuickCheck2 +
-import Test.HUnit +
-import Test.QuickCheck+
  
 import qualified Lib as Lib import qualified Lib as Lib
  
 main :: IO () main :: IO ()
-main = defaultMainWithOpts +main = ...
-       [ testCase "rev" testRev +
-       , testProperty "listRevRevId" propListRevRevId +
-       ] mempty+
  
-testRev :: Assertion +...
-testRev = Lib.reverse2 [1, 2, 3] @?= [3, 2, 1]+
  
-propListRevRevId :: [Int] -> Property 
-propListRevRevId xs = not (null xs) ==> Lib.reverse2 (Lib.reverse2 xs) == xs 
 </code> </code>
   - Run ''stack test'' and it will build your tests and run the tests   - Run ''stack test'' and it will build your tests and run the tests
     * <code>     * <code>
-Test1-0.1.0.0: unregistering (dependencies changed) +... 
-Test1> configure (lib + exe + test) +</code>
-Configuring Test1-0.1.0.0... +
-Test1> build (lib + exe + test) +
-Preprocessing library for Test1-0.1.0.0.. +
-Building library for Test1-0.1.0.0.. +
-[1 of 2] Compiling Lib +
-[2 of 2] Compiling Paths_Test1 +
-Preprocessing executable 'Test1-exe' for Test1-0.1.0.0.. +
-Building executable 'Test1-exe' for Test1-0.1.0.0.. +
-[1 of 2] Compiling Main [Lib changed] +
-[2 of 2] Compiling Paths_Test1 +
-Linking .stack-work\dist\274b403a\build\Test1-exe\Test1-exe.exe ... +
-Preprocessing test suite 'Test1-test' for Test1-0.1.0.0.. +
-Building test suite 'Test1-test' for Test1-0.1.0.0.. +
-[2 of 2] Compiling Main +
-Linking .stack-work\dist\274b403a\build\Test1-test\Test1-test.exe ... +
-Test1> copy/register +
-Installing library in ...\Test1\.stack-work\install\261a8b8d\lib\x86_64-windows-ghc-8.10.4\Test1-0.1.0.0-584XNC80AeFHEA877FoaQr +
-Installing executable Test1-exe in ...\Test1\.stack-work\install\261a8b8d\bin +
-Registering library for Test1-0.1.0.0.. +
-Test1test (suite: Test1-test) +
- +
-rev: [OK] +
-listRevRevId: [OK, passed 100 tests]+
  
-         Properties  Test Cases  Total 
- Passed  1                     2 
- Failed  0                     0 
- Total                       2 
  
-Test1> Test suite Test1-test passed +===== ✎ ===== 
-Completed 2 action(s).</code>+~~DISCUSSION~~
toolsetup/testframework.1616263125.txt.gz · Last modified: (external edit)

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki