The ooRexx test framework allows one to create a test group with test cases by 
simply subclassing
the class ooTestCase.

If the subclass has a need for a constructor (defines the method 'INIT'), then 
it is mandatory to
invoke the constructor in its superclass otherwise a runtime error will occur.

E.g. defining a Rexx test group named "defaultMethods.testGroup" like this:

    ... cut ...
    ::class "testDefaultMethods" subclass ooTestCase public

    ::method init
      expose pkgName
      say self
    ... cut ...

will cause an error like:

    
F:\work\svn\bsf4oorexx\trunk\bsf4oorexx.dev\testUnits\bsf4rexx\java8\defaultMethods>rexx
 defaultMethods.testGroup
      1722 *-* return fName
      1733 *-* return "testCase:" pp(self~getName) "(a" || addN(className) 
className || "@" || -          self~definedInFile")"
        68 *-* say self
           *-* Compiled method "NEW" with scope "Object".
      1808 *-*                   self~addTest(testCaseClass~new(name))
       516 *-* forward class (super) continue
           *-* Compiled method "NEW" with scope "Object".
      1503 *-*   suite = .ooTestSuite~new(tClass)
        54 *-* testResult = group~suite~execute~~print
    Error 98 running F:\work\svn\oorexx\test\trunk\framework\OOREXXUNIT.CLS 
line 1722:  Execution error.
    Error 98.986:  Reference to unassigned variable "FNAME".

Unfortunateyl, the error message does not really point to the cause, that the 
superclass' 'init'
method was not invoked.
[Ultimately this error goes back to the fact that the ooRexx test framework 
added the "::OPTIONS
NOVALUE ERROR" directive sometimes after this directive was introduced to 
ooRexx (which in principle
is good).]

So, to save you (potentially a *lot* of) time: whenever you have a need for a 
constructor (the
method named 'init') in your test group, the *first thing* you should do is 
invoke the superclass
constructor to avoid such runtime errors, e.g. like this:

    ... cut ...
    ::class "testDefaultMethods" subclass ooTestCase public

    ::method init
      expose pkgName

      *forward class (super) continue /* let the superclass first initialize 
everything it needs */*
      say "self:" self
    ... cut ...

which would output in this case:

    
F:\work\svn\bsf4oorexx\trunk\bsf4oorexx.dev\testUnits\bsf4rexx\java8\defaultMethods>rexx
 defaultMethods.testGroup
    self: testCase: [TEST_01] (a 
testDefaultMethods@F:\work\svn\testUnits\bsf4rexx\java8\defaultMethods\defaultMethods.testGroup)

---rony

_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to