Return-Path: list-help: list-unsubscribe: List-Post: List-Id: Mailing-List: contact cactus-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list cactus-user@jakarta.apache.org Received: (qmail 49247 invoked by uid 99); 7 May 2005 14:52:32 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from i216-58-12-104.avalonworks.net (HELO stalker.server) (216.58.12.104) by apache.org (qpsmtpd/0.28) with ESMTP; Sat, 07 May 2005 07:52:32 -0700 Received: from [192.168.1.100] ([192.168.1.1]) by stalker.server (Merak 8.0.3) with ESMTP (SSL) id QVS40753 for ; Sat, 07 May 2005 10:49:35 -0400 Message-ID: <427CD57F.3020105@bbs.darktech.org> Date: Sat, 07 May 2005 10:49:35 -0400 From: Gili User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Cactus Users List Subject: Re: Contacting the container from beginXXX() Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked Vincent Massol wrote: > Gili, > > It's important to choose the right type of test for the job so that the test > is as easy as possible to write/maintain. > > Here are some ideas: > > * It seems strange that you don't control the data in the database. For > testing it's a good idea to control what you put in the database. If you do > then you know exactly what's in there and you shouldn't need to call the > database to get test input data from it. Right, I might go in this direction but it requires me to use two different Hibernate mapping files: one for production builds (IDs are generated automatically) and one for test builds (IDs are provided by the developer). It just makes things a bit more complicated. > * Calling the database to get a fixture seems too complex to me and it seems > what you really want to do is a functional test (not an integration or unit > test). How are you running your functional tests? Why don't you add this > test to your suite of functional tests? I don't know what one uses for functional tests (and how these differ from unit tests). I was under the impression that Cactus could be used for this. > * If you really need to perform a unit test, I would suggest that you don't > hit the database at all, using a MockObjects/Stub approach instead (pure > JUnit without Cactus). That will allow you to test the code logic in unit > tests. Then you couple this with a functional test and you should get a > pretty good coverage I don't think there is an easy way to stub out the Hibernate objects. Sounds like way too much work for too little gain. > All that said, if you still want to use Cactus you should be able to write > the following in your beginXXX() method: > > String serverURL = System.getProperty("cactus.contextURL"); I suspect (but please let me know) that the webapp to be tested is not deployed by the time beginXXX() is called and it is only deployed before testXXX(). I already tried hitting localhost:8080 (which is my test server address) and got an HTTP which I think was due to a webapp not deployed error. If you can think of an easier way than using different Hibernate mapping files and generating IDs manually, please let me know :) Thank you, Gili