• 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: Christian Pekeler <email@hidden>
  • Date: Thu, 7 Dec 2006 09:28:54 -0700

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

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: Xcode and WOUnitTest 2
      • From: Denis Frolov <email@hidden>
    • Re: Xcode and WOUnitTest 2
      • From: Eugene Khablov <email@hidden>
References: 
 >Re: Xcode and WOUnitTest 2 (From: Eugene Khablov <email@hidden>)

  • Prev by Date: Re: Question about Session
  • Next by Date: RE: Bug in stateless WOComponent management?
  • Previous by thread: Re: Xcode and WOUnitTest 2
  • Next by thread: Re: Xcode and WOUnitTest 2
  • Index(es):
    • Date
    • Thread