Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
JUnit vs. Spock – What's Wrong with JUnit (jakubdziworski.github.io)
4 points by jakubdziworski on May 15, 2016 | hide | past | favorite | 3 comments


> Spock is that it’s basically a DSL (domain specifing language) for writing tests. It’s based on Groovy

I don't like the way Spock hacks Groovy's syntax for its DSL. The "expect" and "where" are actually labels that can be jumped to, repurposed as some sort of macro word. The | and || are operators for something else. Other languages don't even allow boolean op || to be overloadable.

It's like Spock has gone to a lot of trouble to work around the restrictions in Groovy's antiquated Antlr 2.7 based grammar.

  class Math extends Specification {
      def "maximum of two numbers"(int a, int b, int c) {
          expect:
          Math.max(a, b) == c

          where:
          a | b || c
          3 | 5 || 5
          7 | 0 || 7
          0 | 0 || 0
      }
  }


> Other languages don't even allow boolean op || to be overloadable.

Some languages don't allow overloading any operator, but of the ones that do, several allow || to be overloaded. Ruby doesn't, but C++ does for example.


I wonder if you can combine spock with cucumber




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: