Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Test Isolation with ScalaTest?

Received: by 10.216.144.28 with SMTP id m28mr2836wej.8.1282602963988;
        Mon, 23 Aug 2010 15:36:03 -0700 (PDT)
X-BeenThere: scalatest-users@googlegroups.com
Received: by 10.216.237.165 with SMTP id y37ls2252793weq.1.p; Mon, 23 Aug 2010
 15:36:03 -0700 (PDT)
Received: by 10.216.174.74 with SMTP id w52mr309491wel.3.1282602963086;
        Mon, 23 Aug 2010 15:36:03 -0700 (PDT)
Received: by 10.216.174.74 with SMTP id w52mr309490wel.3.1282602963051;
        Mon, 23 Aug 2010 15:36:03 -0700 (PDT)
Return-Path: <esko.luont...@gmail.com>
Received: from mail-wy0-f176.google.com (mail-wy0-f176.google.com [74.125.82.176])
        by gmr-mx.google.com with ESMTP id x37si2405767weq.8.2010.08.23.15.36.01;
        Mon, 23 Aug 2010 15:36:02 -0700 (PDT)
Received-SPF: pass (google.com: domain of esko.luont...@gmail.com designates 74.125.82.176 as permitted sender) client-ip=74.125.82.176;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of esko.luont...@gmail.com designates 74.125.82.176 as permitted sender) smtp.mail=esko.luont...@gmail.com; dkim=pass (test mode) header...@gmail.com
Received: by wyb35 with SMTP id 35so7942214wyb.21
        for <scalatest-users@googlegroups.com>; Mon, 23 Aug 2010 15:36:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=gamma;
        h=domainkey-signature:received:received:message-id:date:from
         :user-agent:mime-version:to:subject:references:in-reply-to
         :content-type:content-transfer-encoding;
        bh=4BGaicEF9UktXrlblOmBlKIjreCfl+gdqtD2Fpvpers=;
        b=GAk0HccszBNwmkikHbcpf53R9EksFDiEak1iXday76bOkZLLbCAFq4aax93ga0Ax9w
         0HxnR0PVxB57M9SIsmQXrTCVVld+qryLu0N+jIG2Ai6jVTIU+b+Cjz4RJbxchHxKvJKN
         f1B59RbqITwJEtZq4h1hgDBPpJRIb/KzLlCG4=
DomainKey-Signature: a=rsa-sha1; c=nofws;
        d=gmail.com; s=gamma;
        h=message-id:date:from:user-agent:mime-version:to:subject:references
         :in-reply-to:content-type:content-transfer-encoding;
        b=xvGIs9QLkyBrLqYQ1ofD2xpi71DUHWkmqTnGMetSR7fp6VIz86eyB2zSrL7MOK1UbC
         zxgeMfR84QPC7CI82PNTTr1jBWZ9MWnZGaDQMcJvDV3M+zXS+NJaYJHwFTxT86qkyBkb
         uCg9Q/Yvu/Ad4G0ni7B3Sz/v0o4D5Q0gXi3tA=
Received: by 10.227.41.2 with SMTP id m2mr5149830wbe.12.1282602957290;
        Mon, 23 Aug 2010 15:35:57 -0700 (PDT)
Return-Path: <esko.luont...@gmail.com>
Received: from [127.0.0.1] (dsl-hkibrasgw2-ff75c300-100.dhcp.inet.fi [88.195.117.100])
        by mx.google.com with ESMTPS id b23sm5609867wbb.16.2010.08.23.15.35.55
        (version=SSLv3 cipher=RC4-MD5);
        Mon, 23 Aug 2010 15:35:56 -0700 (PDT)
Message-ID: <4C72F7C8.1080...@gmail.com>
Date: Tue, 24 Aug 2010 01:35:52 +0300
From: Esko Luontola <esko.luont...@gmail.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2
MIME-Version: 1.0
To: scalatest-users@googlegroups.com
Subject: Re: [scalatest-users] Re: Test Isolation with ScalaTest?
References: <39c628e1-11b2-4d4c-ab4e-47dfc19b1...@s9g2000yqd.googlegroups.com>	<AANLkTik9tgH7NCdyBFLHvCAxX4fP7KWYvSLyP0okK...@mail.gmail.com>	<5055380e-dd6d-42e7-ba89-cf4fcc30a...@j8g2000yqd.googlegroups.com>	<AANLkTi=VZmAiiUnLmO6EFwPUmoHbx6qOd+-3TrfeB...@mail.gmail.com>	<dae1323b-a0c3-4274-8dc0-b04f19ff7...@k19g2000yqc.googlegroups.com>	<AANLkTinCSB=TzhS4s-imzXPyNG+G+sTVz5kjcbj0o...@mail.gmail.com>	<dc9cd6b0-6e31-4655-a419-21ff1e598...@f7g2000vbl.googlegroups.com>	<AANLkTi=3kEWmx_MbrGV3pXHDBKsfeH0vMZTa4cnLH...@mail.gmail.com>	<b8e7c142-b018-4750-9ef7-3e22911b9...@z10g2000yqb.googlegroups.com>	<AANLkTikrFeLfTUDxHhxeihsD2uJmnJXEmUciD+mw=...@mail.gmail.com>	<dbd0c150-0707-4460-b04f-f31e909a6...@q12g2000yqj.googlegroups.com>	<AANLkTimPPJM9mS=r=Uw3jH-Zc59hL+WwDcY_Ag_rm...@mail.gmail.com>	<4C726CEB.60...@gmail.com>	<AANLkTin-PaimaFUmK2vbJKbX7_M-BKTC809_EQRd-...@mail.gmail.com>	<4C72D417.3070...@gmail.com> <AANLkTi=O+kbZLtUVYqH4D7PvkH2XoSgbV-HuHZa+j...@mail.gmail.com>
In-Reply-To: <AANLkTi=O+kbZLtUVYqH4D7PvkH2XoSgbV-HuHZa+j...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Bill Venners wrote on 24.8.2010 0:00:
> If scala-library.jar is a problem then ScalaTest is out of the
> "running" for sure. But I actually don't understand what you mean
> here, and would like to. Can you clarify by giving a specific example
> of code you would want to "execute before the test class is
> instantiated?"

There's this line which passes the context to the test, so that the test 
will know that which tests to execute on the current test run, and the 
initialization in the Context.bootstrap() method:
http://github.com/orfjackal/specsy/blob/master/src/main/scala/net/orfjackal/specsy/core/SpecClassRunner.scala#L12

It would be possible to detect when the class is instantiated the first 
time by the framework (when no context has been prepared), but having to 
deal with that special case would complicate the code needlessly. It 
leads to a cleaner design when the test runner is separated from the 
test class. Now calling the root spec (the test code in the constructor) 
can be handled the same way as calling the nested specs - in 
http://github.com/orfjackal/specsy/blob/master/src/main/scala/net/orfjackal/specsy/core/Context.scala#L18-42 
the bootstrap() method is for the root spec and the specify() method for 
the nested specs - the only differences relate to changing the running 
status.

Probably also writing tests for the testing framework code would be 
harder, if the test runner would be coupled with the test class. Now I 
can test the framework by just passing closures to the test runner (for 
example 
http://github.com/orfjackal/specsy/blob/master/src/test/scala/net/orfjackal/specsy/ExecutionModelTest.scala) 
instead of having to creating a dummy class whose constructor contains 
the test code. There are only a couple of tests (for the JUnit runner 
and the code itself which instantiates the classes) which require 
concrete dummy classes as test data.

I suppose it basically boils down to this: 
http://michaelfeathers.typepad.com/michael_feathers_blog/2010/08/testng-and-what-wed-like-code-to-be.html


> I have a new question about after. Should multiple after clauses be
> allowed in a block, and if so, what order are they executed on exit?
> I'm guessing yes, and last registered first executed (i.e. executed in
> reverse order of appearance).  Is that what you do in Specsy?

Yes, that's how I do it. See the chapter "Before" and "After" Blocks in 
http://github.com/orfjackal/specsy#readme


> This is
> another example of how such code would not be obvious to casual
> readers without reading the documentation, but again, it would likely
> be rare and could be well documented.

Specsy's documentation (http://github.com/orfjackal/specsy#readme) is 
only about 4 pages long and it consists mostly of code examples (the 
most valuable kind of documentation). I'm expecting everybody to read it 
before using the framework.

-- 
Esko Luontola
www.orfjackal.net