Re: Running one junit test method from package explorer

From: Kaj Hejer (kaj.heje..sit.uio.no)
Date: Thu Mar 03 2005 - 09:25:43 EST

  • Next message: wolip..atos.de: "Re: WOLips problem with WEBSERVER_RESOURCES"

    Hi!

    We use WOUnitTest for our junit test in WO applications. See
    <url:http://wounittest.sourceforge.net/> for more info.

    To get the application you just need the following in your setup-method:

    Application.primeApplication(null,
    NSBundle.mainBundle().bundlePathURL(), "Application");

    and then I guess you can say

    Application a = (Application) WOApplication.application();

    (I havn't tried the last line myself).

    Another thing about running junittests this way:

    We have some propertiesfiles in the Resources directory so we need to
    have the Resources directory in the classpath. When running a
    WO-application from eclipse we just add
    ./build/myapp.woa/Contents/Resources to the buildpath for the projectt,
    but it looks like that work when running junit tests. I havn't look so
    much into this issue yet, but please let me know if anyone here have
    any hints.

    -Kaj :)

    On 3. mar 2005, at 12.23, wolip..atos.de wrote:

    > Hello Kaj,
    >
    > I used to use JUnit for Java Applications(none WO).
    > I thought to do the same with the WO, but I got problems with creating
    > an
    > Object from :
    > Application a = new Application();
    >
    > my question is weather its possible to use JUnit without any extra
    > stuff/Packages in WOLips/ WebObjects?
    >
    > Thank you,
    > Sako.
    >
    > ----- Original Message -----
    > From: "Kaj Hejer" <kaj.heje..sit.uio.no>
    > To: <woproject-de..bjectstyle.org>
    > Sent: Wednesday, March 02, 2005 10:06 PM
    > Subject: Re: Running one junit test method from package explorer
    >
    >
    > Hi!
    >
    > This is solved! :)
    >
    > By adding
    >
    > if (EOModelGroup.defaultGroup().modelNamed(modelName) ==
    > null) {
    > EOModelGroup.defaultGroup().addModelWithPathURL(
    > new File(modelName + ".eomodeld").toURL());
    > }
    >
    >
    > to the setup-method we can run our unittests from package explorer as
    > described.
    >
    >
    > -Kaj :)
    >
    >
    > On 2. mar 2005, at 19.33, Ulrich Köster wrote:
    >
    >> Moin Kaj,
    >>
    >> please add a request to jira. Could take a while.
    >>
    >> Ulrich
    >>
    >> Am 22.02.2005 um 10:27 schrieb Kaj Hejer:
    >>
    >>> Hi!
    >>>
    >>> I'm doing some other javadevelopment in eclipse too (spring and so on
    >>> :) and then I can run just one junit test method from package
    >>> explorer by finding the testclass in package explorer and open it so
    >>> I see all the methods it contains. Then I just right-click the
    >>> testmethod I want to run and run->kunit test.
    >>>
    >>> When I try this for a testclass in a WO project (which is using some
    >>> database stuff) in eclipse I get the following:
    >>>
    >>>
    >>> com.webobjects.eoaccess.EOObjectNotAvailableException:
    >>> databaseContextForModelNamed: cannot find model named skjema
    >>> associated with this EOEditingContext
    >>> at
    >>> com.webobjects.eoaccess.EOUtilities.databaseContextForModelNamed(EOUt
    >>> i
    >>> lities.java:769)
    >>> at Session.isProdDatabase(Session.java:348)
    >>> at NettskjemaTestCase.setUp(NettskjemaTestCase.java:62)
    >>> at com.codefab.wounittest.WOUTTestCase.runBare(Unknown Source)
    >>> at junit.framework.TestResult$1.protect(TestResult.java:106)
    >>> at junit.framework.TestResult.runProtected(TestResult.java:124)
    >>> at junit.framework.TestResult.run(TestResult.java:109)
    >>> at junit.framework.TestCase.run(TestCase.java:118)
    >>> at
    >>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(Remot
    >>> e
    >>> TestRunner.java:421)
    >>> at
    >>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTest
    >>> R
    >>> unner.java:305)
    >>> at
    >>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTes
    >>> t
    >>> Runner.java:186)
    >>>
    >>> It seems that if I first run the testclass the "normal way" by
    >>> defining a runsetup for it and then from the junit-view right-click
    >>> some of the tests and select run, the test runs just fine.
    >>>
    >>>
    >>> Should I add a feature request to wolips for the posibility to run a
    >>> single junit test method in WO projects from package explorer or is
    >>> this something that would be alot of work to implement?
    >>>
    >>>
    >>> -Kaj :)
    >>>
    >>>
    >>
    >
    >
    >





    This archive was generated by hypermail 2.0.0 : Thu Mar 03 2005 - 09:27:36 EST