-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retrofit Groovy language track tests as Spock specifications #31
Conversation
Other exercises seem to point to the Exercism.io documentation. Also, instructions for importing into IntelliJ (or other IDE) seems better off kept as advanced instructions. The tests can be run directly from the command line with edits in any editor (or IDE). These instructions may not be as complete as we'd like, but I feel we muddy the waters less by keeping the basic instructions on the simple side.
- Fix indentation - Make test cases match canonical - Implement IllegalArgumentException, per canonical data
Thanks so much @Dispader! @kimdbarnes do you have time to look at this? (I promise I'm going to look for Groovy track maintainers really, really soon ❤️!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ignore is misspelled in this sentence: "+After the first test(s) pass, continue by commenting out or removing the @Ingore
annotations prepending other tests."
Except for the above misspelling, it looks good to me! |
I see |
@Grab('org.spockframework:spock-core:1.0-groovy-2.4') | ||
import spock.lang.* | ||
|
||
class SquaresSpec extends Specification { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test are a good chance to show off Spock's parameterised tests with something like this for each one:
@Unroll
def 'can square the sum of the numbers up to the given number: #num'() {
expect:
new Squares(num).squareOfSums() == expected
where:
num || expected
5 || 225
10 || 3025
100 || 25502500
}
I think this is a accurate implementation of the various test using Spock. I would give my 👍 |
class HelloWorldSpec extends Specification { | ||
|
||
def 'outputs "Hello, World!"'() { | ||
expect: new HelloWorld().hello() == 'Hello, World!' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have the expect
and other tags on separate lines.
And I would extract the class instantiation to a field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gijsleussink I was also wondering about this one— you think that we should introduce helloWorld
as a test case variable?
I could get behind that, but I was almost considering making the call static
, since our calls just output text, and don't modify any object state, which would make the calls HelloWorld.hello()
.
If we went as far as a static get
method, the call could look like HelloWorld.hello
.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in this case it simplifies. I read the Hello-World exercise and you mainly focus on getting the concept of TDD across. So why not keep the Spec as simple and easily readable as possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gijsleussink What d'you think, sir?
@Grab('org.spockframework:spock-core:1.0-groovy-2.4') | ||
import spock.lang.* | ||
|
||
class HammingSpec extends Specification { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it's mentioned somewhere else (in the exercise?), but if I only look at this spec I wouldn't know (the overview of) what a Hamming-distance is and what the letters stand for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An exercise is assembled from various sources. For example, the description for The Hamming exercise can be found at x-common/exercises/hamming
@mattphillips I'm always 👍 on Gradle, but to my mind |
@tlberglund I'm not a Groovy dev but |
@@ -7,6 +7,6 @@ Run the tests by executing the test script. | |||
$ groovy ./HelloWorldSpec.groovy | |||
``` | |||
|
|||
After the first test(s) pass, continue by commenting out or removing the `@Ingore` annotations prepending other tests. | |||
After the first test(s) pass, continue by commenting out or removing the `@Ignore` annotations prepending other tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kimdbarnes !
Oh, |
@mattphillips in general I'd agree, however on Exercism we're explicitly targeting a high level of fluency at only the language syntax / standard library / idioms / conventions level, not the larger platform / tool / real-world-codebase level. |
Thanks everyone, for the discussion! |
Hey, everyone.
So— I should type up something more descriptive, but I'd rather start the process of having someone look at this Pull request (because I'm sure that it could use some work).
This Pull is an attempt to retrofit tests as Spock specifications for the Groovy track up through the
phone-number
exercise, as discussed in this Pull.