Running EasyB Specs From Gradle

Although the cookbook includes an example of using the easyb ant task to run specs and produce reports, I thought I’d try my hand at writing a task to manually run easyb specifications from the commandline. Here’s the result:

task spec <<{
    ant.java(classname:'org.easyb.BehaviorRunner', fork:false,
      classpath: "${sourceSets.test.runtimeClasspath.asPath}")  {
        sourceSets.test.java.srcDirs.each { testDir ->
            testDir.eachDirRecurse { dir ->
                dir.eachFileMatch(~/.*\.specification/){spec->
                    arg(value:spec.absolutePath)
                }
            }
        }
    }
}

Now I can run “gradle spec” from the commandline to write all my easyb specs. Spock is next.

I’ll admit I’ve just recently gotten back into groovy, so I’m still kind of a noob. I keep feeling like groovy has a better way to search for file patterns recursively. :)

You can leave a response, or trackback from your own site.

Facebook comments:

2 Responses to “Running EasyB Specs From Gradle”

  1. Hans Dockter says:

    Hi James,

    alternatively you can use the Gradle API for the filtering.

    sourceSets.java.allSource.matching { include “**/*.specification” }.each { specFile ->
    arg(value: specFile)
    }

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!