commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/junit CaseTag.java
Date Mon, 19 Aug 2002 16:15:22 GMT
jstrachan    2002/08/19 09:15:22

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/junit
                        CaseTag.java
  Log:
  Patch so that in JellyUnit, each <test:case> has its own variable scope, so that JellyUnit
test cases cannot step on each others toes.
  
  Note that the scope for each <test:case> is a child of the <test:suite> scope,
so that global variables can be shared, per <test:suite> across individual <test:case>
test cases.
  e.g.
  
  <test:suite>
     <!-- define some global variables... -->
    <j:set var="g" value="abc"/>
  
    <test:case>
  
       <!-- variables I define will be local -->
      <j:set var="foo" value="1234"/>	
  
       // however I can refer to global variable ${g} if required
      ...
  
  Revision  Changes    Path
  1.2       +7 -2      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/junit/CaseTag.java
  
  Index: CaseTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/junit/CaseTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CaseTag.java	22 Jul 2002 07:58:49 -0000	1.1
  +++ CaseTag.java	19 Aug 2002 16:15:21 -0000	1.2
  @@ -64,7 +64,7 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  -
  +import org.apache.commons.jelly.JellyContext;
   import org.apache.commons.jelly.JellyException;
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
  @@ -93,7 +93,12 @@
           // or something?
           TestCase testCase = new TestCase(name) {
               protected void runTest() throws Throwable {
  -                invokeBody(output);
  +                // create a new child context so that each test case
  +                // will have its own variable scopes
  +                JellyContext newContext = new JellyContext( context );
  +                
  +                // invoke the test case
  +                getBody().run(newContext, output);
               }
           };
           
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message