BTD
build-test-deploy Development Environment

TestClass.lua

Internal use : contains test class LuaNMP code, reporting,... Supports following switches :
Abort
Coupling test methods is not exactly standard unit testing procedure, so here is a way to break that rule...
local test = require('btd.lua.testapi)
...
TestClass = {}
TestClass.Serial = true

TestClass:test1Method()
  ... -- test1Method test clauses
end
TestClass:test2Method()
  if self.abort then return end
  TestClass.test1Method(self) -- call test1Method (or write it again)
  ... -- (incremental) test2Method test clauses
end
The idea is that, to spare your sore eyes from having to scroll through enormous error listings, testing a run of Serial'ised test methods can be aborted when one of them fails. This might come in handy when having a lot of incremental test cases (eg. GUI testing). The other test methods will terminate normally. When using this functionality the serialised test methods should have names that reflect the order of the incremental tests (alphabetically sorted).
local test = require('btd.lua.testapi)
...
TestClass = {}

TestClass.Abort = true
TestClass.Serial = true

TestClass:testMethod1() -- will be run before testMethod2
  test.equals(function using common resource,b)
end

TestClass:testMethod2() -- will be run after testMethod1 if testMethod1 didn't fail
  test.equals(function using common resource,b)
end
Serial (all methods)
Normally all methods will be run in parallel, which might give problems when they need the same resources (file, socket, screen,...). This can be avoided by setting the serial flag, after which all methods in the test class will be run one by one (and in alphabetical order).
local test = require('btd.lua.testapi)
...
TestClass = {}

TestClass.Serial = true

TestClass:testMethod1() -- will be run before testMethod2
  test.equals(function using common resource,b)
end

TestClass:testMethod2() -- will be run after testMethod1
  test.equals(function using common resource,b)
end
Serial (specific methods)
If only some test methods use the same resources they can be individually marked. In this case only one of the marked test methods can be active (all none marked methods keep running in parallel, even to the marked ones).
local test = require('btd.lua.testapi)
...
TestClass = {}

TestClass.testMethod1Serial = true
TestClass:testMethod1() -- will be run before testMethod2
  test.equals(function using common resource,b)
end

TestClass.testMethod2Serial = true
TestClass:testMethod2() -- will be run after testMethod1
  test.equals(function using common resource,b)
end

TestClass:testMethod2() -- will be run concurrently with testMethod1 and/or testMethod2
  test.equals(function using common resource,b)
end
Time
It is possible to limit the maximum time a test method may run. After this time the violating method will be aborted.
local test = require('btd.lua.testapi)
...
TestClass = {}

TestClass.testMethodTime = 1.5 -- test must terminate within 1.5 s
TestClass:testMethod()
  test.equals(a,b)
end