ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <jakarta-...@ehatchersolutions.com>
Subject Re: JUnit: setUp() method called multiple times ?
Date Thu, 03 Oct 2002 08:57:16 GMT
Correct.  This is just the way JUnit works (regardless of it being run 
from Ant or otherwise).  setUp(), testXXX, tearDown().... setUp(), 
testZZZ(), tearDown() - that is the JUnit-way, call setUp(), then a test 
method, then tearDown() repeatedly.

	Erik

otisg wrote:
> I believe that's normal.
> I've observed the same behaviour with Ant 1.4.1.
> 
> Otis
> 
> 
> ---- On Thu, 03 Oct 2002, P. Fleury
> (fleury@users.sourceforge.net) wrote:
> 
> 
>>Hello,
>>
>>I have a single test class which has
> 
> setUp() method. When I run it 
> 
>>through the junit task, in batch, the
> 
> setUp method gets called once for 
> 
>>each test. Is that the normal behavior ?
> 
> My problem is that multiple 
> 
>>runs of setUp make things fail...
>>
>>Anybody having similar issues?  Ant 1.5,
> 
> Sun's JDK 1.4.0_01, Linux 
> 
>>RH7.3, JUnit 3.7
>>
>>--Pascal
>>
>>###Here is the stub of my class (partially
> 
> generated by NetBeans):
> 
>>public class JNIContentManagerTest extends
> 
> TestCase {
> 
>>       public
> 
> JNIContentManagerTest(java.lang.String
> testName) {
> 
>>        super(testName);
>>    }
>>   
>>    public static void
> 
> main(java.lang.String[] args) {
> 
>>        junit.textui.TestRunner.run(suite());
>>    }
>>   
>>    public static Test suite() {
>>        TestSuite suite = new
> 
> TestSuite(JNIContentManagerTest.class);
> 
>>        return suite;
>>    }
>>   
>>    private MockContentManagerLink cml = null;
>>    private JNIContentManager    jnicm = null;
>>   
>>    private static int count_setups = 0;
>>   
>>    protected void setUp()  {
>>        count_setups++;
>>        System.err.println("setup
> 
> #"+count_setups+" called.");
> 
>>        // do initialization
>>    }
>>   
>>    public void
> 
> testMultipleContentManagerLink() {
> 
>>       
> 
> System.out.println("testMultipleContentManagerLink");
>             
> 
>>    }
>>   
>>   
>>    /** Test of createNewReference method,
> 
> of class 
> 
>>com.sony.vesta.jnicm.JNIContentManager. */
>>    public void testCreateNewReference() {
>>       
> 
> System.out.println("testCreateNewReference");
>      
> 
>>    }
>>   
>>    /** Test of getFilename method, of class 
>>com.sony.vesta.jnicm.JNIContentManager. */
>>    public void testGetFilename() {
>>        System.out.println("testGetFilename");
>>    }
>>      
>>}
>>
>>### Ant the JUnit task:
>>      <junit fork="true" dir="${lib.dir}">
>>         <formatter extension=".xml"
> 
> type="xml" usefile="true"/>
> 
>>         <classpath refid="class.path"/>
>>            <sysproperty
> 
> key="java.library.path" 
> 
> value="${ld.library.path}:${env.LD_LIBRARY_PATH}"/>
> 
>>            <jvmarg value="-Xcheck:jni"/>
>>            <batchtest fork="true"
> 
> todir="${testresults.dir}">
> 
>>                <fileset dir="${class.dir}">
>>                    <include
> 
> name="**/*Test.class"/>
> 
>>                </fileset>
>>            </batchtest>
>>      </junit>
>>
>>
>>
>>
>>--
>>To unsubscribe, e-mail:  
> 
> <mailto:ant-user-unsubscribe@jakarta.apache.org>
> 
>>For additional commands, e-mail:
> 
> <mailto:ant-user-help@jakarta.apache.org>
> 
>>
>>
> 
> 
> ________________________________________________
> Get your own "800" number
> Voicemail, fax, email, and a lot more
> http://www.ureach.com/reg/tag
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
> 
> 
> 


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


Mime
View raw message