vendredi 24 juillet 2020

Why Spock suggest no indentation after labels?

I'm wondering why Spock, in its official documentation suggests using no indentation after labels. E.g. here:

def "events are published to all subscribers"() {
  given:
  def subscriber1 = Mock(Subscriber)
  def subscriber2 = Mock(Subscriber)
  def publisher = new Publisher()
  publisher.add(subscriber1)
  publisher.add(subscriber2)

  when:
  publisher.fire("event")

  then:
  1 * subscriber1.receive("event")
  1 * subscriber2.receive("event")
}

Don't you think that having indent after each label, would increase readability of tests, especially long ones, e.g.:

def "events are published to all subscribers"() {
  given:
    def subscriber1 = Mock(Subscriber)
    def subscriber2 = Mock(Subscriber)
    def publisher = new Publisher()
    publisher.add(subscriber1)
    publisher.add(subscriber2)

  when:
    publisher.fire("event")

  then:
    1 * subscriber1.receive("event")
    1 * subscriber2.receive("event")
}

?

Aucun commentaire:

Enregistrer un commentaire