Another option: Write your tests in Groovy, which lets you access private fields. (Of course you'll get other benefits from using Groovy. In short, it's a much better language for testing, especially when combined with Spock.)
Cheers, Peter Christian Edward Gruber-3 wrote: > > Hey, > > So @Property is beautiful, but sometimes when I'm testing the > thin controller logic that remains I want access to an @Property from > within the test in order to verify that something was done/changed. > I've looked at PageTester, but I don't want to dig into the rendered > document, because I'm really just testing the java logic. But I also > don't want to create accessors for my test objects alone. > > I've looked around and found PageTester, Testify, and tapestry- > xpath, but nothing that I can run the component through that will add > accessors/mutators for the @Property-annotated fields so my tests can > access them. I'm thinking something along the lines of: > > public void testFoo() { > MyComponent foo = UnitTester.manifest(MyComponent.class); > UnitTester.assign(foo, "bar", someBar); > foo.doSomething(); > assertEquals(anotherBar, UnitTester.obtain(foo, "bar")); > } > > ... where MyComponent.bar is a field with @Property. There's > really no need to create an accessor just for this, and certainly no > need to render the component - I don't care about its rendering, just > its code. > > Anything that might solve the problem this way? Or any > recommendations from Howard or others on where to start to build > something like this myself? I'm not very familiar with the > classloader stuff we do in T5 and the javassist work... if I am going > to do this myself, I'll need some good hints as to where to start > looking. > > cheers, > Christian. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > > -- View this message in context: http://old.nabble.com/Component-.java-file-unit-testing-and-%40Property-tp28823028p28918663.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org