Tests: Difference between revisions

1 byte added ,  21 July 2017
m
Minor text revision and corrections, add category Category:Testing.
(→‎Error: added %!warning and checking for particular ids)
m (Minor text revision and corrections, add category Category:Testing.)
Line 18: Line 18:
{{codeline|mean()}}:
{{codeline|mean()}}:


  octave-cli-3.8.2> test mean
  >> test mean
  PASSES 17 out of 17 tests
  PASSES 17 out of 17 tests


Line 27: Line 27:
installation.  The whole Octave test suite can be ran with:
installation.  The whole Octave test suite can be ran with:


  octave-cli-3.8.2> __run_test_suite__
  >> __run_test_suite__
   
   
  Integrated test scripts:
  Integrated test scripts:
Line 108: Line 108:
=== Assert ===
=== Assert ===


{{codeline|%!assert}} lines are simplest tests to write and also the most
{{codeline|%!assert}} lines are the simplest tests to write and also the most
common:
common:


  %!assert (foo (bar))      # test fails if "foo (bar)" returns false
  %!assert (foo (bar))      # test fails if "foo (bar)" returns false
  %!assert (foo (bar), qux) # test fails if "foo (bar)" is different from "qux
  %!assert (foo (bar), qux) # test fails if "foo (bar)" is different from "qux"


These are actually a shorthand version of
These are actually a shorthand version of
{{codeline|%!test assert (foo (bar))}}, and {{codeline|assert}} is simply
{{codeline|%!test assert (foo (bar))}}, and {{codeline|assert}} is simply
an Octave function that throws errors when two arguments fail to compare.
an Octave function that throws an error when two arguments fail to compare.


=== Test ===
=== Test ===


While single line {{codeline|%!assert}}s are the most common test used,
While single {{codeline|%!assert}} lines are the most common used tests, {{codeline|%!test}} blocks offer more features and flexibility. The code within {{codeline|%!test}} blocks is simply processed through the Octave interpreter.  If the code generates an error, the test is said to fail.  Often {{codeline|%!test}} blocks end with a call to {{codeline|assert}}:
{{codeline|%!test}} blocks are the ultimate, most useful, and flexible.
The code within such block is simply processed through the Octave interpreter
and if the code generates an error, then the test is said to fail.  These
often end with a call to {{codeline|assert}}:


  %!test
  %!test
Line 177: Line 173:




== Code coverage ==
[[Category:Testing]]
 
[[Category:Development]]
[[Category:Development]]