diff options
Diffstat (limited to 'web/input/doc/faq/nptest.md')
| -rw-r--r-- | web/input/doc/faq/nptest.md | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/web/input/doc/faq/nptest.md b/web/input/doc/faq/nptest.md new file mode 100644 index 0000000..71fda44 --- /dev/null +++ b/web/input/doc/faq/nptest.md | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | title: NPTest | ||
| 2 | parent: FAQ | ||
| 3 | --- | ||
| 4 | |||
| 5 | # How do the NPTest parameters work? | ||
| 6 | |||
| 7 | NPTest.pm is a perl module, originally written by Peter Bray, and provides | ||
| 8 | some basic functions for testing the plugins. It has two main helpers: | ||
| 9 | `getTestParameter` and `testCmd`. | ||
| 10 | |||
| 11 | ## getTestParameter | ||
| 12 | |||
| 13 | Used to get parameters given in previous test runs. Use the 3 parameter | ||
| 14 | version (the 4 parameter version is deprecated). | ||
| 15 | |||
| 16 | Saved parameters are put in `/var/tmp/NPTest.cache`. Unfortunately, there is | ||
| 17 | no easy way of altering this - you will have to manually change this file to | ||
| 18 | edit existing parameters. | ||
| 19 | |||
| 20 | If you are adding new parameters, there are three values for the parameters | ||
| 21 | that you need to be aware of: | ||
| 22 | |||
| 23 | * default value | ||
| 24 | * the value that you check against in the test script | ||
| 25 | * an empty string, which is returned by getTestParameter when the test is run | ||
| 26 | via automated testing (technically, when no terminal is associated to the | ||
| 27 | test run) | ||
| 28 | |||
| 29 | You should try and ensure current tests are not affected when a new parameter | ||
| 30 | is added. So it may be better to say `NP_INTERNET_ACCESS`, with information | ||
| 31 | like *default "yes", disable with "no"* and check for | ||
| 32 | `NP_INTERNET_ACCESS == "no"` to skip the tests. | ||
| 33 | |||
| 34 | ## testCmd | ||
| 35 | |||
| 36 | This runs a command and returns an NPTest object back. You can combine | ||
| 37 | Test::More routines with the object to get the return code, output or perf | ||
| 38 | data to test against expected values. | ||
| 39 | |||
| 40 | See `plugins/t/check_disk.t` as an example test script. | ||
| 41 | |||
| 42 | <!--% # vim:set filetype=markdown textwidth=78 joinspaces: # %--> | ||
