general/unittest - Unit Test Framework

Typical framework for test-driven development.
Test units are defined in individual script file.
Main verb unittest file is defined in the z locale.

See also: examples in demo folder in SVN; change history.

Installation

Use JAL/Package Manager.

Usage

Naming conventions

Procedure

Test execution can be controlled with attributes:

Setup and tear down code can be executed before and after all and each test verb, when the following verbs are defined in the test script: before_all, after_all, before_each, after_each.

Examples

«demo/one_test.ijs»=
before_all=: 3 : 0
  require'files'
)

test_add=: 3 : 0
  assert 4 = 2+2
)

test_fexist=: 3 : 0
  assert fexist jpath'~help/index1.htm'
)

ex1_expect=: 'domain error'
test_ex1=: 3 : 0
  2+'2'
)

ig2_ignore=: 1
test_ig2=: 3 : 0
  2+2
)

with the test run:


«demo/two_test.ijs»=
before_each=: 3 : 0
  smoutput 'before ',y
)

after_each=: 3 : 0
  smoutput 'after ',y
)

test_rplc=: 3 : 0
  require 'strings'
  assert'zz123' -: 'qq123' rplc 'qq';'zz'
)

test_bad=: 3 : 0
  require 'strings'
  assert'qq123' -: 'qq123' rplc 'qq';'zz'
)

ex2_expect=: 'value error'
test_ex2=: 3 : 0
  dummy 123
) 

with the test run:

See Also


Contributed by OlegKobchenko

Addons/general/unittest (last edited 2009-09-23 10:25:30 by RicSherlock)