Search code examples
unit-testingtestinggroovyspock

Why Spock Framework recommends to use SUS, but there is no such abbreviation in any example?


Spock framework states that we should use SUS abbreviation for testing entity, but never uses it itself.

Here is the morsel from documentation: Spock Terminology

Here are Spock official examples from GitHub

What is the right one?

For example:

class EmptyStackSpec extends Specification {
  def stack = new Stack()

  def "size"() {
    expect: stack.size() == 0
  }
}

OR

class EmptyStackSpec extends Specification {
  def sus = new Stack()

  def "size"() {
    expect: sus.size() == 0
  }
}

So, I'm puzzled. Why does it present in docs if nobody uses it?


Solution

  • If you want to indicate the Class that is being tested, Spock has the @Subject annotation for that. The paragraph you linked, doesn't mean that you should actually call the field/variable sus, rather it gives you the term to talk about it in an abstract way. If you actually write a specification it is often more helpful to use more descriptive names.