• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JUnit testing outside Eclipse
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JUnit testing outside Eclipse


  • Subject: Re: JUnit testing outside Eclipse
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 9 Aug 2010 16:36:07 -0700

See below.


On Aug 9, 2010, at 4:22 PM, Paul Hoadley wrote:

> On 07/08/2010, at 12:02 PM, Paul Hoadley wrote:
>
>> On 07/08/2010, at 1:18 AM, Chuck Hill wrote:
>>
>>> Yes?  Are you using the WO-fu of wopath?
>>
>> I am now!  Thanks Chuck.
>
> Now I'm testing a framework that contains some EOs.  Again, this is using Ant + JUnit, and outside of Eclipse.  Inside Eclipse, I don't seem to have to do much at all in the way of setting things up to get the model loaded.  In fact, it seems to happen somewhat magically, and I just provide a dummy connection dictionary for the model in a @BeforeClass method, and point it at an (empty) in-memory H2 database.
>
> From the command line (and in Hudson) I get this:
>
>     [junit] Attempt to insert null into an com.webobjects.foundation.NSMutableArray.
>     [junit] java.lang.IllegalArgumentException: Attempt to insert null into an com.webobjects.foundation.NSMutableArray.
>     [junit] 	at com.webobjects.foundation.NSMutableArray.addObject(NSMutableArray.java:165)
>     [junit] 	at com.webobjects.eoaccess.EOModelGroup.modelGroupForLoadedBundles(EOModelGroup.java:700)
>     [junit] 	at com.webobjects.eoaccess.EOModelGroup.globalModelGroup(EOModelGroup.java:306)
>     [junit] 	at com.webobjects.eoaccess.EOModelGroup.defaultGroup(EOModelGroup.java:333)
>     [junit] 	at net.logicsquad.webobjects.core.LSEOModelUtils.setUpDatabaseConnectionForModel(Unknown Source)
>     [junit] 	at net.logicsquad.pbf.tests.model.ModelTest.setUp(Unknown Source)
>     [junit] 	at net.logicsquad.pbf.tests.model.bookings.BookingsModelTest.setUp(Unknown Source)
>
>
> Some Googling lead me to believe that this is a symptom of the main bundle not being loaded, and, indeed, NSBundle.mainBundle() returns null.  Is it obvious what I'm doing wrong here?  I'm using the same Ant targets (appended below) as I am for a different framework projects (i.e., neither of them are applications), the only difference here is that I am trying to load an EOModel.
>
> ---
> 	<!-- JUnit testing -->
> 	<property name="src.tests" value="Tests" />
> 	<property name="bin.tests" value="bin-tests" />
> 	<property name="junit.results" value="junit-results" />
> 	<property name="junit.report" value="junit-report" />
>
> 	<target name="clean.tests">
> 		<delete dir="${bin.tests}" />
> 		<delete dir="${junit.results}" />
> 		<delete dir="${junit.report}" />
> 	</target>
>
> 	<typedef name="wopath" classname="org.objectstyle.woproject.ant.WOPath" />
> 	<wopath id="testing.classpath">
> 		<frameworks root="User" eclipse="true" />
> 		<frameworks root="Local" eclipse="true" />
> 		<frameworks root="System" eclipse="true" />
> 	</wopath>
>
> 	<target name="compile.tests">
> 		<mkdir dir="${bin.tests}" />
> 		<javac srcdir="${src.tests}" destdir="${bin.tests}">
> 			<classpath refid="testing.classpath" />
> 			<classpath>
> 				<pathelement location="bin" />
> 			</classpath>
> 		</javac>
> 	</target>
>
> 	<target name="junit" depends="compile.tests">
> 		<mkdir dir="junit-results" />
> 		<junit haltonfailure="false"
> 			   printsummary="true"
> 			   failureproperty="test.failed">

You need to add dir to the junit task.  e.g.

        <junit dir="${project.working.directory}" ...

Where the directory depends on the project type:

    <!-- Initialize properties that depend on build type (build or install) with values unique to applications  -->
    <target name="set_application_build_properties" depends="load.properties" if="is.wo.app" >
        <property name="build.product.dir" value="${dest.dir}${file.separator}${build.app.name}.woa"/>
        <property name="installed.product.dir" value="${install.dir}${file.separator}${build.app.name}.woa"/>
        <property name="project.working.directory" value="${build.product.dir}"/>
        <property name="project.java.dir" value="${build.product.dir}${file.separator}Contents${file.separator}Resources${file.separator}Java"/>
    </target>


    <!-- Initialize properties  that depend on build type (build or install) with values unique to frameworks  -->
    <target name="set_framework_build_properties" depends="load.properties" if="is.wo.framework" >
        <property name="build.product.dir" value="${dest.dir}${file.separator}${project.name}.framework"/>
        <property name="installed.product.dir" value="${install.dir}${file.separator}${project.name}.framework"/>
    	<!-- Use the installed location as that will be populated for regular and install builds -->
        <property name="project.working.directory" value="${install.dir}${file.separator}${project.name}.framework${file.separator}Resources${file.separator}Java"/>
        <property name="project.java.dir" value="${project.working.directory}"/>
    </target>


Chuck


> 			<classpath refid="testing.classpath" />
> 			<classpath>
> 				<pathelement location="bin" />
> 				<pathelement location="${junit.jar}" />
> 				<pathelement location="${bin.tests}" />
> 			</classpath>
> 			<formatter type="brief" usefile="false" />
> 			<formatter type="xml" />
> 			<batchtest todir="${junit.results}">
> 				<fileset dir="${bin.tests}" includes="**/ClinicalDetailsTest.class" />
> 			</batchtest>
> 		</junit>
> 		<mkdir dir="${junit.report}" />
> 		<junitreport todir="${junit.report}">
> 			<fileset dir="${junit.results}">
> 				<include name="TEST-*.xml"/>
> 			</fileset>
> 			<report format="frames" todir="${junit.report}"/>
> 		</junitreport>
> 		<fail if="test.failed"/>
> 	</target>
> ---
>
>
> --
> Paul.
>
> http://logicsquad.net/
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

--
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects







Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: JUnit testing outside Eclipse
      • From: Paul Hoadley <email@hidden>
References: 
 >JUnit testing outside Eclipse (From: Paul Hoadley <email@hidden>)
 >Re: JUnit testing outside Eclipse (From: Chuck Hill <email@hidden>)
 >Re: JUnit testing outside Eclipse (From: Paul Hoadley <email@hidden>)
 >Re: JUnit testing outside Eclipse (From: Paul Hoadley <email@hidden>)

  • Prev by Date: Re: JUnit testing outside Eclipse
  • Next by Date: Re: NSNotificationCenter.defaultCenter().postNotification("EONewCommandmentNotification", null)
  • Previous by thread: Re: JUnit testing outside Eclipse
  • Next by thread: Re: JUnit testing outside Eclipse
  • Index(es):
    • Date
    • Thread