[jala-dev] Re: Test framework error handling

  • From: "Hannes Wallnoefer" <hannesw@xxxxxxxxx>
  • To: jala-dev@xxxxxxxxxxxxx
  • Date: Wed, 21 Mar 2007 11:34:47 +0100

Sorry, forgot to append the patch. Here it is.

h.

2007/3/21, Hannes Wallnoefer <hannesw@xxxxxxxxx>:
Hi list,

I'm in the process of setting up a Jala test suite for the recent skin
enhancements in Helma 1.6. First, let me say that the Jala testing
framework is simply wonderful. Thanks a lot for the great conception
and implementation. (I haven't had the opportunity to use any other
part of Jala yet, but I surely will do so soon.)

The one problem I have with the framework is that it stops testing on
the first failure. I'm not sure what the motivation is here, but I
think this is rather unusual for a testing framework. It is quite
common to have tests fail, also over a longer period of time. If
people only wrote tests for things that alreay work, it would only be
half as useful IMO.

I was able to change the behaviour quite easily by adding a try/catch
statement within the loop that runs the tests. It's quite simple, and
I don't think it should cause any problems.

BTW, this issue was also mentioned by one novice Helma developer with
a solid testing background here at Systemone as a problem he saw with
the Jala testing framework. If this could be fixed, he'd really really
like Helma a whole :-)

hannes

--- /home/hannes/downloads/jala/util/Test/code/Global/jala.Test.js      
2007-02-27 15:27:02.000000000 +0100
+++ util/Test/code/Global/jala.Test.js  2007-03-21 11:04:42.000000000 +0100
@@ -535,11 +535,17 @@
          var functionName;
          for (var i=0;i<scope.tests.length;i++) {
             functionName = scope.tests[i];
-            if (!scope[functionName] || scope[functionName].constructor != 
Function) {
-               throw new jala.Test.EvaluatorException("Test function '" +
-                                         functionName + "' is not defined.");
+            try {
+               if (!scope[functionName] || scope[functionName].constructor != 
Function) {
+                 throw new jala.Test.EvaluatorException("Test function '" +
+                                           functionName + "' is not defined.");
+              }
+              testResult.log[testResult.log.length] = 
this.executeTestFunction(functionName, scope);
+            } catch (e) {
+              this.testsFailed += 1;
+              testResult.status = jala.Test.FAILED;
+              testResult.log[testResult.log.length] = new 
jala.Test.EvaluatorException(e.toString());
             }
-            testResult.log[testResult.log.length] = 
this.executeTestFunction(functionName, scope);
          }
       } catch (e) {
          this.testsFailed += 1;

Other related posts: