60.14.1. ShUnit

60.14.1.1. Analýza skriptů

ShUnit je ke stažení z Source Forge. Poslední dostupná verze (k 2005-06-02) je verze 1.2 z 2004-12-24.

Po stažení a rozbalení balíčku jsem objevil tyto soubory:

radek@yoda:~/tmp/ShUnit-1.2$ ls -l
celkem 32
-rw-r--r--    1 radek    radek         415 pro 24 05:45 logTest
-rw-r--r--    1 radek    radek         632 pro 24 05:45 monitorTestAndNotify
-rw-r--r--    1 radek    radek         433 pro 24 05:45 notify
-rw-r--r--    1 radek    radek        3947 pro 24 05:45 shUnit
-rw-r--r--    1 radek    radek        1545 pro 24 05:45 shUnitPlus
-rw-r--r--    1 radek    radek        1941 pro 24 05:45 shUnitPlusTest
-rw-r--r--    1 radek    radek        1871 dub 26  2004 shUnitPlusTestFailing
-rw-r--r--    1 radek    radek         828 pro 24 05:45 shUnitTest

FIXME:

Použití:

  1. Write a script.
  2. In the 'main' of the script, the shUnit functions have to be sourced in ( . /wherever/the/shUnit/file/is/shUnit)
  3. Create a function in your test scripts that prepares the environment in which your test will be run
  4. Again in the main, call the shuStart function with the name of the initia lization function as an argument.
  5. For each testfunction, perform these steps:

    1. Add a line to the initialization function to register the testfunction. This will look like: shuRegTest NameOfTestFunction
    2. Create a function NameOfTestFuction that

      1. executes whatever you wish to test
      2. Checks the result of what you've just tested
      3. Calls the shuAssert function to assert that the result is as expected
      4. You can put as many asserts as you wish in each testfunction.
  6. Run your testscript

1. Write a script.
2. In the 'main' of the script, the shUnit functions have to be sourced in ( . /wherever/the/shUnit/file/is/shUnit)
3. Create a function in your test scripts that prepares the environment in which your test will be run
4. Again in the main, call the shuStart function with the name of the initialization function as an argument.
5. For each testfunction, perform these steps:
   5.1. Add a line to the initialization function to register the testfunction. This will look like: shuRegTest NameOfTestFunction
   5.2. Create a function NameOfTestFuction that
        5.2.1. executes whatever you wish to test
        5.2.2. Checks the result of what you've just tested
        5.2.3. Calls the shuAssert function to assert that the result is as expected
        5.2.4. You can put as many asserts as you wish in each testfunction.
6. Run your testscript

You can of course repeat step 5 as much as you like (many testfunctions).