You'll probably find better examples online, but in my Test classes I
usually have a method like this:


private MyDAO<MyPojo,MyQueryObject> dao;
@BeforeClass
public void beforeClass() {

// TODO Auto-generated constructor stub
System.out.println("MyDAOTest");
Registry registry;
RegistryBuilder builder = new RegistryBuilder();
builder.add(MyDAOModule.class);
registry = builder.build();
registry.performRegistryStartup();
dao = registry.getService(MyDAO.class);

}

@Test
public void f() {
MyQueryObject q = new MyQueryObject();
q.setAttribute("Martin");
List<MyPojo> = dao.findByQuery(q);
//assert something here
}


In MyDAOModule.class, you can set up your services to build via
auto-binding, interface binding, or using a build method (public static
MyDAO buildMyDAO() { ... }  )
depending on your needs.


On Mon, Sep 23, 2013 at 2:58 PM, Martin Kersten <martin.kersten...@gmail.com
> wrote:

> Is there anything to aid me with the usual service test. Currently I use
> constructors to ease setup of the services. I will try out providing a test
> module setting up the services and use tapestry IOC to create those. Should
> have done so more early on, but wanted it simple first. But now when I have
> three or four services to setup it becomes cumbersome.
>
>
> 2013/9/23 Martin Kersten <martin.kersten...@gmail.com>
>
> > Thanks daniel. I will check the testify stuff in a real example.
> >
> >
> > 2013/9/23 Daniel Jue <teamp...@gmail.com>
> >
> >> I don't have spare minutes at the moment, I just want to drop these
> links
> >> for you to look at (if you haven't seen them already).  Hope it helps.
> >>
> >>
> http://blog.tapestry5.de/index.php/2010/11/16/improved-testing-facilities/
> >>
> >> and then this one
> >>
> >> http://blog.tapestry5.de/index.php/2010/11/18/find-your-elements/
> >>
> >>
> >> Dan
> >>
> >>
> >> On Mon, Sep 23, 2013 at 12:49 PM, Martin Kersten <
> >> martin.kersten...@gmail.com> wrote:
> >>
> >> > Problems nope. I just habe to overhowle the system and wonder what
> >> people
> >> > nicht use. I will check your base clase out. Thanks for sharing.
> >> > Am 23.09.2013 18:12 schrieb "Dmitry Gusev" <dmitry.gu...@gmail.com>:
> >> >
> >> > > I use JUnit for unit testing with T5 services, and TestNG for
> (smoke)
> >> > > integration testing my apps with URLs.
> >> > >
> >> > > All my JUnit test classes inherited from BaseIntegrationTest (
> >> > > https://gist.github.com/dmitrygusev/6672859),
> >> > > all TestNG classes inherited from a copy of SeleniumTestCase with
> with
> >> > this
> >> > > patch applied:
> >> > > https://issues.apache.org/jira/browse/TAP5-2107
> >> > >
> >> > > Which is something you may already read while browsing the web.
> >> > >
> >> > > Do you have any problems with this?
> >> > >
> >> > >
> >> > > On Mon, Sep 23, 2013 at 7:02 PM, Martin Kersten <
> >> > > martin.kersten...@gmail.com
> >> > > > wrote:
> >> > >
> >> > > > I want some real hands on experiences. So please if you have any
> >> please
> >> > > > provide.
> >> > > >
> >> > > > I am currently reworking the testing settup since the maven stuff
> >> is to
> >> > > > slow for my program test cycle.
> >> > > >
> >> > > > Since I wont use testng I need to rewrite some test code. I need
> to
> >> do
> >> > > unit
> >> > > > testing in java
> >> > > > since I program in java. Integration test and Acceptance test may
> be
> >> > done
> >> > > > in groovy
> >> > > > but I am in doupt this would be such a gain.
> >> > > >
> >> > > > Well the unit testing I want to elaborate the IOC directly using
> >> only a
> >> > > > fraction of the
> >> > > > services the application is about. The IOC setup seams to be
> fairly
> >> > fast
> >> > > so
> >> > > > it is ok
> >> > > > (Hibernate takes way longer)
> >> > > >
> >> > > > I use a embedded jetty for the integration testing with a presetup
> >> in
> >> > > > memory database (h2).
> >> > > >
> >> > > > I dont use mvn jetty:run since it is dead slow with all the
> >> dependency
> >> > > > setup and stuff.
> >> > > >
> >> > > > So in the end I want to hear what you use for testing, what speed
> >> means
> >> > > and
> >> > > > if you
> >> > > > use IOC, jetty or something else.
> >> > > >
> >> > > >
> >> > > > And yes I searched the web high and low, I want just personal
> >> > experiences
> >> > > > with
> >> > > > the background of embedding either a web application server or an
> >> IOC.
> >> > > >
> >> > > >
> >> > > > Cheers,
> >> > > >
> >> > > > Martin (Kersten)
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > --
> >> > > Dmitry Gusev
> >> > >
> >> > > AnjLab Team
> >> > > http://anjlab.com
> >> > >
> >> >
> >>
> >
> >
>

Reply via email to