-
-
Save ldaley/341949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spock For Non-Believers | |
Which code would you rather want to read, write, and maintain? Choose the right answer and win a trip to Vulcan! | |
A. B. | |
/* Seven lines of imports removed for clarity */ /* Zero lines of imports removed for clarity */ | |
@RunWith(Parameterized.class) class HelloSpock extends spock.lang.Specification { | |
public class HelloSpock { def "length of Spock and friends"() { | |
private String name; expect: | |
private int length; name.length() == length | |
public HelloSpock(String name, int length) { where: | |
this.name = name; name | length | |
this.length = length; "Spock" | 5 | |
} "Kirk" | 4 | |
"Scotty" | 6 | |
@Test } | |
public void lengthOfSpockAndFriends() { } | |
assertEquals(length, name.length()); | |
} | |
@Parameters | |
public static List<Object[]> data() { | |
return Arrays.asList(new Object[][] | |
{{"Spock", 5}, {"Kirk", 4}, {"Scotty", 6}}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment