Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 38340 invoked from network); 7 Nov 2009 21:59:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Nov 2009 21:59:08 -0000 Received: (qmail 19167 invoked by uid 500); 7 Nov 2009 21:59:07 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 19100 invoked by uid 500); 7 Nov 2009 21:59:07 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 19090 invoked by uid 99); 7 Nov 2009 21:59:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Nov 2009 21:59:07 +0000 X-ASF-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of b.candler@pobox.com designates 208.72.237.25 as permitted sender) Received: from [208.72.237.25] (HELO sasl.smtp.pobox.com) (208.72.237.25) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Nov 2009 21:59:04 +0000 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id BA321786CB for ; Sat, 7 Nov 2009 16:58:43 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :subject:message-id:references:mime-version:content-type :in-reply-to:content-transfer-encoding; s=sasl; bh=EIhuaxpzJnCd2 3TA2xlUwwyguW4=; b=qChM0YRGSvytXIQZqYTSPY+L+SnF181Dja3DMwcgYWfLH eGxZWTlYFg/6HAFMSEkz2k5zHM6F8ghxm+K6RrtZfVeimsNFo8H/4vpZcH9ZmUrR YExr8higGGCsrYMq8FZDIQ3YGRMjh8B5V+BDP8b/zthVRA2wGgZf1MckxkDlW4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=date:from:to :subject:message-id:references:mime-version:content-type :in-reply-to:content-transfer-encoding; q=dns; s=sasl; b=R2qddMy R/RN2ttCR8C57S9dpSq/hnCIm7tx93Io45POEa7PH3sxtJPF0XgSSylklgzmOjmX 7w8nix3GQ7GhaC/qE+hqHBYxzZvI/P9P9iVZ0CIbq6xceAMIlemeFzPqESTEgNjl FevNnKYiCtw753l6gYEEACdYkPhl2VIXiP4s= Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id B70E0786CA for ; Sat, 7 Nov 2009 16:58:43 -0500 (EST) Received: from mappit (unknown [80.45.95.114]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 67ABE786C7 for ; Sat, 7 Nov 2009 16:58:43 -0500 (EST) Received: from brian by mappit with local (Exim 4.69) (envelope-from ) id 1N6tIv-0002SE-PR for user@couchdb.apache.org; Sat, 07 Nov 2009 21:58:41 +0000 Date: Sat, 7 Nov 2009 21:58:41 +0000 From: Brian Candler To: user@couchdb.apache.org Subject: Re: Tests/TDD for CouchDB views Message-ID: <20091107215841.GC9046@uk.tiscali.com> Mail-Followup-To: user@couchdb.apache.org References: <177E2090-776A-4C2D-9BFB-89BF4F074DFB@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <177E2090-776A-4C2D-9BFB-89BF4F074DFB@gmail.com> User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Pobox-Relay-ID: B76252A4-CBE8-11DE-B0ED-7C40EE7EF46B-28021239!a-pb-sasl-quonix.pobox.com Content-Transfer-Encoding: quoted-printable On Sat, Nov 07, 2009 at 02:31:04PM +0100, Karel Mina=C5=99=C3=ADk wrote: > So, my questions are basically these: > > * How do would you write/implement tests for your views? I don't see in principle why it can't be any different to normal tests. T= hat is, you write tests within your application testing framework which: - setup a database and some sample data - perform a view query - check the results are what you expect > * What is the recommended practice for writing the views? In Futon? In = =20 > an editor and uploading them to db via couchapp or similar? Via =20 > CouchRest or similar layer? I do the latter (using my own CouchTiny rather than CouchRest). Your view= s are source-controlled together with the rest of your application, your application can populate the design docs when required, and you can integrate your view tests with your application tests just as you wish. > * Is it possible to write views "test-first|driven", ie. setting up som= e=20 > fixtures, writing the view, etc? Does it even make sense in CouchDB=20 > context? I think so, if the test is part of your application (e.g. your applicatio= n is in Ruby and you're using something like CouchRest to manage your desig= n docs). View tests are just exercising another part of your app. > * Is there a way to automatically run such test suites? (Via browser, o= r=20 > something like Rhino?) Same. > * Regarding application logic itself, what would be the best/preferred = =20 > way to test CouchDB-backed models in eg. Rails app? Using eg. FakeWeb =20 > [4] to mock responses and work with those? Or setting up and using =20 > another CouchDB database (like Rails does for *SQL dbs)? You can set up 'test', 'development' and 'production' environments for CouchDB just as ActiveRecord does, and this is how I handle it. See http://github.com/candlerb/couchtiny/blob/master/doc/RAILS.rdoc Note: this is for my own CouchTiny, which is subject to change at my personal whim so I wouldn't recommend anyone to depend on it right now, b= ut you should be able to apply the same approach to CouchRest. Regards, Brian.