• 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: Xcode and WOUnitTest 2
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode and WOUnitTest 2


  • Subject: Re: Xcode and WOUnitTest 2
  • From: Eugene Khablov <email@hidden>
  • Date: Fri, 08 Dec 2006 11:11:58 +0300
  • Thread-topic: Xcode and WOUnitTest 2

Title: Re: Xcode and WOUnitTest 2
Christian,

Thanks for the answer! I’ve looked through our code and it seems like a solution.

Regards,
Eugene

On 12/7/06 7:28 PM, "Christian Pekeler" <email@hidden> wrote:

> EOEnterpriseObjectClazz.objectWithPrimaryKeyValue(ec, pk);
> or
> EOUtilities.objectWithPrimaryKeyValue(ec, entity, pk);
>
> These methods create qualifiers against primary key attribute which  
> is not  selected as a class property in model.

Why do you fetch objects by their primary key? I don't mean to sound  
condescending, but I don't think I've ever had to do this in my 8  
years of working with WO.

Anyways, the MockEditingContext is meant for testing in memory. It  
can't handle hard-coded sql, raw rows, or access to non-property  
attributes. One way around this is to factor out any such code into  
extra methods and stub them out for unit testing. For example:

public class Blah {

 public String foo() {
  ...
  ... someEO();
  ...
 }

 protected SomeEO someEO() {
  return (SomeEO)EOUtilities.objectWithPrimaryKeyValue(...);
 }
}

public class BlahTest {

 static class TestBlah extends Blah {
  SomeEO someEO;
  @Override
  protected SomeEO someEO() {
   return someEO;
  }
 }

 @Test
 public void foo() {
  TestBlah blah = new TestBlah();
  blah.someEO = mockEditingContext().createSavedObject(SomeEO.class);
  assertEquals("...", blah.foo());
 }

}

Christian


_______________________________________________
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

 _______________________________________________
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

References: 
 >Re: Xcode and WOUnitTest 2 (From: Christian Pekeler <email@hidden>)

  • Prev by Date: Re-[SOLVED] why not true when testing for equality with a null query
  • Next by Date: Re: Xcode and WOUnitTest 2
  • Previous by thread: Re: Xcode and WOUnitTest 2
  • Next by thread: Re: Xcode and WOUnitTest 2
  • Index(es):
    • Date
    • Thread