triggering junit.xml output in standalone Spock script.groovy

85 views
Skip to first unread message

Mark Hudson

unread,
Jan 26, 2017, 1:36:50 PM1/26/17
to Spock Framework - User
Given the below ultra-simple test script, I'm trying to figure out how to get junit.xml output.
When I run this, I only get a one-line on-screen summary to STDOUT:
JUnit 4 Runner, Tests: 1, Failures: 0, Time: 71

script:

#!/usr/bin/env groovy

@Grab(group='org.spockframework', module='spock-core', version='1.0-groovy-2.4')  // @Grapes()
import spock.lang.*  // pulls in non-defaults like @Unroll() and @Requires()

class HelloSpockSpec extends spock.lang.Specification {

  def "example single assertion about Spock"() {
    given:  "setup initial data"
      def attrStr = "logical"
    when:   "tweak data"
      def SpockAttr = attrStr
    then:   "assertions"
      SpockAttr == 'logical'
      println "0. PASS: ok -- SpockAttr == 'logical'"
  }

}

// EOF

How can I get junit.xml output? Note I'm not running under Maven or Gradle.

Mark Hudson

unread,
Jan 31, 2017, 4:46:21 PM1/31/17
to Spock Framework - User
Starting to figure out that Spock relies in jUnit for some things, like xUnit.XML output.
There may be a way to @Grab the right part of jUnit.
But for now, I experimented with converting my standalone script to be initiated by Maven.
The steps were:
1. import the @Grab Grapes into Maven XML <dependency> block(s).
2. comment out the @Grab lines. (There may be a way to either enable Maven to not choke, or conditionalize those.)
Reply all
Reply to author
Forward
0 new messages