Thanks for the detail replay it helps me to figure out the best way to organise everything.
btw once you have everything registered how do you get a service? cheers On Thu, Sep 26, 2013 at 12:38 AM, Martin Kersten < martin.kersten...@gmail.com> wrote: > Hi Boris, > > I just use a registery builder and add the sub modules I need to test > (as already mentioned). Often > I use public TestModule static classes that reside into the TestCase class. > Then I just use those TestModule > classes to build the registry. They contain often only the services needed > using bind(ServiceImpl.class) which > makes it quite easy to use special bindings and only a fraction of the > application sub modules of this BI parts. > > I use a H2 inmemory setup to get everything related to unit tests done > quickly. For setup I use the appropriated > services and sometimes I use the entities directly. Depends on the > situation and use case. Often I use the same > entities in different services dealing those differently or altering them > (like one serivce creates a task and another > one picks it up and alters and process it). > > I also have limited unit tests where I simply setup hibernate directly, add > the required entity classes and wire up and > instanciate the services directly but I am almost ever come back later and > replace those with using a RegistryBuilder. > > One thing that you need to consider is that your HibernateConfigurer > instances must be different for the application > and the test. I have an AppModule and a TestModule and also I have sub > modules with the configuration. Therefore > I just add a InMemoryTestDatabaseModule and get the hibernate configuration > for the in memory test database. > Also this module is in src/test/java rather then in the src/main/java. > > The rest is as straight forward as you actually wrote. Usually one use > state-testing rather then behavior-testing. > So you setup, modify, verify the state of the database. There are rare > occursions I use behavior testing and using > a mocking framework for injecting services and replace those. > > > Cheers, > > Martin (Kersten) > > > > 2013/9/22 Boris Horvat <horvat.z.bo...@gmail.com> > > > Hi all, > > > > How does one make a proper testing of the business layer in tapestry > that I > > inject into the page as a service? Is there anything specific that one > > needs to look out for? > > > > Should I simple do something like > > > > 1) Create an object of the BU layer > > 2) Mock hibernate with some in-memory db > > 3) Call methods of the BU layer > > 4) Verify the results > > > > Any test example that I can check out? Any projects with a nice testing > > environments that one can recommend? > > > > Thanks > > > > -- > > Sincerely > > *Boris Horvat* > > > -- Sincerely *Boris Horvat*