Account Options

  1. Sign in
Google Groups Home
« Groups Home
Spock 0.5 released
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Niederwieser  
View profile  
 More options Dec 10 2010, 8:50 pm
From: Peter Niederwieser <pnied...@gmail.com>
Date: Fri, 10 Dec 2010 17:50:54 -0800 (PST)
Local: Fri, Dec 10 2010 8:50 pm
Subject: Spock 0.5 released
Dear Spock community,

I'm happy to announce that Spock 0.5 has been released!

What's New
==========

1. Comprehensive support for Hamcrest matchers
----------------------------------------------

Hamcrest matchers are now deeply integrated with Spock's condition
mechanism, allowing you to write code like:

expect:
myPi closeTo(Math.PI, 0.01)

View/run the full example in Spock Web Console: http://meet.spockframework.org/?id=22001

2. Optimization of spec run order
---------------------------------

If enabled, recently failed spec classes/methods will be run first to
provide faster feedback.

3. New built-in extensions
-------------------------

@spock.lang.AutoCleanup
@spock.util.mop.Use
@spock.util.mop.ConfineMetaClassChanges

See the JavaDoc for more information.

4. Better integration with Grails, Maven, and Ant
-------------------------------------------------

Among other things, the Grails plugin is now packaged differently to
solve installation problems.

5. Support for Groovy 1.8
-------------------------

There is now a Spock distribution for Groovy 1.8 (beta-2 and
later).

6. Diff view in Eclipse and IDEA
--------------------------------

Say you have a failing object comparison like:

expect: ["fred", "chris", "tom"] == ["fred", "chriz", "tom"]

Click the first line (Eclipse) or link (IDEA) in the failure output to
open a diff view comparing the two objects. This works for arbitrary
types of objects. Kudos to FEST-Assert (http://fest.easytesting.org/)
for the idea!

7. Better Eclipse and IDEA integration
--------------------------------------

As always, we have worked with the folks behind Groovy-Eclipse and
IDEA to provide the best possible IDE experience.

8. Other improvements and fixes
-------------------------------

Here is the full list of closed issues:
http://issues.spockframework.org/list?can=1&q=label%3AMilestone-0.5

How To Get It
=============

Spock 0.5 comes in three distributions for Groovy 1.6, 1.7, and 1.8,
respectively. All Jars are available from Maven Central:
http://repo1.maven.org/maven2/org/spockframework

The Spock Grails plugin comes in two distributions for Grails 1.2 and
1.3, respectively. See http://grails.org/plugin/spock for more
information.

The Spock Example project can be downloaded from http://downloads.spockframework.org

And last but not least, Spock Web Console has been updated too:
http://meet.spockframework.org

Acknowledgments
===============

Thanks to everyone who provided ideas, feedback, patches, or helped to
promote Spock. Please keep supporting us!

What's Up Next
==============

0.6 will be a smaller and quicker release. Main goal is to write a
comprehensive Spock manual.

Have fun with Spock!
Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hamlet D'Arcy  
View profile  
 More options Dec 11 2010, 1:46 am
From: "Hamlet D'Arcy" <hamlet...@gmail.com>
Date: Sat, 11 Dec 2010 07:46:54 +0100
Local: Sat, Dec 11 2010 1:46 am
Subject: Re: Spock 0.5 released
Awesome! Congrats to the team.

--
Hamlet D'Arcy
hamlet...@gmail.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ale Sarco  
View profile  
 More options Dec 13 2010, 1:04 pm
From: Ale Sarco <sarco...@gmail.com>
Date: Mon, 13 Dec 2010 10:04:38 -0800 (PST)
Local: Mon, Dec 13 2010 1:04 pm
Subject: Re: Spock 0.5 released
In Spock 0.4 I could do something like this:

                then: "I should receive and XML with an OK notification"
                        res.status == 200
                        res.data.text() == "OK"

                and: "The userTemplate should have been updated"
                        res = settingsService.get(path: "templates", query:
[X_Security_Token: token.value])
                        res.status == 200
                        def newTemplate = res.data.userTemplate.find {it.@id ==
newUserTemplateId}
                        println "Retrieved template id is $newUserTemplateId"
                        newTemplate.@id == newUserTemplateId
                        newTemplate.label == "An updated user template"

But Spock 0.5 complains that "Groovy:Expected a condition, but found
an assignment. Did you intend to write '==' ?" on the first line of
the and: block.
Docs says that variables can be defined in when: blocks, and this
worked perfect in Spock 0.4
If this is no longer possible by design, how should I refactor my
test?

On Dec 11, 1:50 am, Peter Niederwieser <pnied...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Niederwieser  
View profile  
 More options Dec 13 2010, 1:36 pm
From: Peter Niederwieser <pnied...@gmail.com>
Date: Mon, 13 Dec 2010 19:36:08 +0100
Local: Mon, Dec 13 2010 1:36 pm
Subject: Re: Spock 0.5 released
On 13.12.2010, at 19:04, Ale Sarco wrote:

> But Spock 0.5 complains that "Groovy:Expected a condition, but found
> an assignment. Did you intend to write '==' ?" on the first line of
> the and: block.
> Docs says that variables can be defined in when: blocks, and this
> worked perfect in Spock 0.4

The problem is in this line:

then:
res = settingsService.get(path: "templates", query: [X_Security_Token: token.value])

This code doesn't declare a new variable, but reassigns an existing one. It is evaluated as a condition and will fail if the assigned value is false according to Groovy truth. This behavior is almost never desirable, and can give rise to nasty bugs. For example, if you write "x = y" when you really meant "x == y", the condition will almost always be true, and will lead you to believe that x and y are equal even when they aren't.

> If this is no longer possible by design, how should I refactor my test?

The solution is to introduce another variable:

then:
def newRes = ...

Hope this helps.

Cheers,
Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ale Sarco  
View profile  
 More options Dec 14 2010, 6:41 am
From: Ale Sarco <sarco...@gmail.com>
Date: Tue, 14 Dec 2010 03:41:51 -0800 (PST)
Local: Tues, Dec 14 2010 6:41 am
Subject: Re: Spock 0.5 released
Hi Peter, thanks for your answer.
Yeah, it helps, partially.

Maybe I'm not using the best practices, since I'm quite new to Groovy
and Spock.
My case is like this, I want to test some REST calls. These REST
service allows me to create, update and delete templates. So I have a
specification to excersice this.

The first method will create a template, then check that the template
has been created, and saves the template id in a variable.
Second method will update the template, then check that the template
has been updated.
Third one will delete the template, then check that it has been
actually deleted.

So, I used to save the templateId in a class variable (annotated with
@Shared) and use it in all my test (so I always work with the same
template)

        @Shared newUserTemplateId = 0

        def "Create a new user template"() {
                when: "I create a new userTemplate with the REST service"
                        def res = settingsService.post(
                            path: "userTemplate",
                            query: [X_Security_Token: token.value,
                                data_xml: """<?xml version="1.0" encoding="UTF-8" standalone="no"?

><blah/>"""]

                         )
                then: "I should receive an XML with the userTemplateId"
                        res.status == 200
                        res.data.toInteger() > 0
                        newUserTemplateId = res.data.text()
                        println "The new templateId is $newUserTemplateId"
        }

If I cannot assign the newUserTemplateId variable in the then: block,
where then? I cannot do it at the end of the when: block because I
still don't know if the call was successful. It would work in the
cleanup: block, but is that the right place?

Thanks,
Alex.

On Dec 13, 6:36 pm, Peter Niederwieser <pnied...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Niederwieser  
View profile  
 More options Dec 14 2010, 9:19 am
From: Peter Niederwieser <pnied...@gmail.com>
Date: Tue, 14 Dec 2010 15:19:25 +0100
Local: Tues, Dec 14 2010 9:19 am
Subject: Re: Spock 0.5 released

Interesting use case. One thing you can do is to introduce a helper method:

void storeTemplateId(res) {
  newUserTemplateId = res.data.text()

}

This helper method can then be called from then-blocks. Note: It's important that the helper method has return type void.

By the way: If your methods are dependent, it can help to annotate the class with @Stepwise. See the JavaDoc for more information.

Cheers,
Peter

On 14.12.2010, at 12:41, Ale Sarco wrote:

----------------------------------------------------------------
Peter Niederwieser
Creator, http://spockframework.org
Committer, http://groovy.codehaus.org
Blogger, http://pniederw.wordpress.com
Chief Engineer, http://smarter-ecommerce.com
pnied...@gmail.com
Twitter: pniederw

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »