Editing Tests

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
Having a thorough [https://en.wikipedia.org/wiki/Test_suite test suite] is something very important which is usually overlooked.  It is an incredible help in preventing regression bugs and quickly assess the status of old code. For example, many packages in Octave Forge become deprecated after losing their maintainer simply because they have no test suite.
+
Having a thorough [http://en.wikipedia.org/wiki/Test_suite test suite] is
 +
something very important which is usually overlooked.  It is an incredible
 +
help in preventing regression bugs and quickly assess the status of old code.
 +
For example, many packages in Octave Forge become deprecated after losing
 +
their maintainer simply because they have no test suite.
  
GNU Octave has multiple tools that help in creating a comprehensive test suite, accessible to both developers and end-users, as detailed on the [http://www.gnu.org/software/octave/doc/interpreter/Test-Functions.html Octave manual]. Basically, test blocks are {{codeline|%!test}} comment blocks, typically at the end of a source file, which are ignored by the Octave interpreter and only read by the {{manual|test}} function.
+
GNU Octave has multiple tools that help in creating a comprehensive test
 +
suite, accessible to both developers and end-users, as detailed on the
 +
[http://www.gnu.org/software/octave/doc/interpreter/Test-Functions.html Octave manual].
 +
Basically, test blocks are {{codeline|%!test}} comment blocks, typically at the
 +
end of a source file, which are ignored by the Octave interpreter and only
 +
read by the {{codeline|test}} function.
  
 
== Running tests ==
 
== Running tests ==
  
To run all the tests of a specific function, simply use the {{manual|test}} command at the Octave prompt.  For example, to run the tests of the Octave function {{manual|mean}} type:
+
To run all the tests of a specific function, simply use the {{codeline|test}}
 +
command at the Octave prompt.  For example, to run the tests in
 +
{{codeline|mean()}}:
  
 
  >> test mean
 
  >> test mean
 
  PASSES 17 out of 17 tests
 
  PASSES 17 out of 17 tests
  
These tests are written in the Octave language [http://hg.savannah.gnu.org/hgweb/octave/file/6443693a176f/scripts/statistics/base/mean.m#l130 at the bottom of <code>mean.m</code>] which defines the {{manual|mean}} function.  It is important that these tests are also available for the end users so they can test the status of their installation.  The whole Octave test suite can be run with:
+
These tests are written in the Octave language at the bottom of the
 +
[http://hg.savannah.gnu.org/hgweb/octave/file/6443693a176f/scripts/statistics/base/mean.m#l130 m file]
 +
which defines {{codeline|mean()}}.  It is important that these tests are
 +
also available for the end users so they can test the status of their
 +
installation.  The whole Octave test suite can be ran with:
  
 
  >> __run_test_suite__
 
  >> __run_test_suite__
Line 27: Line 42:
 
  See the file test/fntests.log for additional details.
 
  See the file test/fntests.log for additional details.
  
To run tests in a specific file, one can simply specify the path instead of a function name:
+
To run tests in a specific file, one can simply specify the path instead of
 +
a function name:
 +
 
 +
  test /full/path/to/file.cc
  
  test /full/path/to/file.m
 
  
 
== Writing tests ==
 
== Writing tests ==

Please note that all contributions to Octave may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Octave:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: