Re: Unit testing logic / EOF
Re: Unit testing logic / EOF
- Subject: Re: Unit testing logic / EOF
- From: Chuck Hill <email@hidden>
- Date: Fri, 23 Nov 2007 09:55:56 -0800
On Nov 23, 2007, at 9:45 AM, Miguel Arroz wrote:
Hi!
LOL! :) Well, that's odd!
Or good design. :-)
I believe that when you run an WOApp, magic happens because there's
an enormous amount of stuff running before the app starts taking
requests.
Well, it does... But why? How?
But when you run it based on the Main class in the test framework,
it's different, that code is not run... I think...
Have faith in the code, Miguel. This isn't Spring.
Could it be that new EOEditingContext() has something like if
( frameworkIsNotInitialized() ) { activateMagicStuff(); } ?
Not quite, but eventually something calls EOModelGroup.defaultGroup()
and then, like magic, it all "just happens".
It's WO. It just goes. All you need to do is to ensure the jars are
on the classpath so that NSBundle can do its thing. The rest, as I
say, just happens. Really, it does. Try it!
Chuck
On 2007/11/23, at 17:37, Chuck Hill wrote:
On Nov 23, 2007, at 9:31 AM, Miguel Arroz wrote:
Hi!
But where's all the stuff needed to load models from the disk,
etc etc etc? IE, the EOF initialization?
Do I need that? Doesn't it "just happen"? I don't see any code
there that does that...
Let's see... Yep, WebObjects.
:-)
Chuck
On 2007/11/23, at 16:34, Chuck Hill wrote:
On Nov 23, 2007, at 8:23 AM, Miguel Arroz wrote:
Hi!
On 2007/11/23, at 02:45, Chuck Hill wrote:
I don't use WOUnitTest nor MockEditingContext. I use a real
EOEditingContext and often fetch from and save to the
database. This makes the test run more slowly than
"traditional" unit tests. However, I think the advantages of
really getting EOF involved (and finding bugs early) outweigh
the slowness.
How exactly is that done? How do you initialize all the
needed stuff to be able to create a new context without
crashing the whole thing?
I don't think that I do anything very special. Let me see...
1. For bundle loading to work properly, you need to use a custom
Working Directory for the JUnit/TestNG launcher:
${workspace_loc:MyFW/dist/MyFW.framework/Resources/Java}
Apps are similar but a different path.
2. Again, for bundle loading, add the jars from the built
framework / application (can be in the projects in the Eclipse
workspace) to the User Entries of the classpath and move above
whatever is there. Do the same for all the frameworks that it
references.
3. The usual connection dictionary setting classes to set things
up and switch prototypes etc.
4. Sometimes I need to call primeApplication, IIRC for component
tests:
WOApplication.primeApplication("MyFW", null,
"net.foo.bar.appserver.FWApplication");
Where FWApplication is a subclass of WOApplication. You can
also leave the last param blank and it will use WOApplication -
sometimes that works for simple stuff.
Chuck
--
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
Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com
--
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
Miguel Arroz
http://www.terminalapp.net
http://www.ipragma.com
--
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
_______________________________________________
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