1 16 package org.apache.commons.jelly.tags.junit; 17 18 import junit.framework.Test; 19 import junit.framework.TestSuite; 20 21 import org.apache.commons.jelly.JellyTagException; 22 import org.apache.commons.jelly.TagSupport; 23 import org.apache.commons.jelly.XMLOutput; 24 25 32 public class SuiteTag extends TagSupport { 33 34 35 private TestSuite suite; 36 37 38 private String var; 39 40 41 private String name; 42 43 public SuiteTag() { 44 } 45 46 49 public void addTest(Test test) { 50 getSuite().addTest(test); 51 } 52 53 public void doTag(XMLOutput output) throws JellyTagException { 56 suite = createSuite(); 57 58 TestSuite parent = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite"); 59 if ( parent == null ) { 60 context.setVariable("org.apache.commons.jelly.junit.suite", suite ); 61 } 62 else { 63 parent.addTest( suite ); 64 } 65 66 invokeBody(output); 67 68 if ( var != null ) { 69 context.setVariable(var, suite); 70 } 71 } 72 73 public TestSuite getSuite() { 76 return suite; 77 } 78 79 82 public void setVar(String var) { 83 this.var = var; 84 } 85 86 89 public String getName() { 90 return name; 91 } 92 93 96 public void setName(String name) { 97 this.name = name; 98 } 99 100 103 106 protected TestSuite createSuite() { 107 if ( name == null ) { 108 return new TestSuite(); 109 } 110 else { 111 return new TestSuite(name); 112 } 113 } 114 } 115 | Popular Tags |