Groovy Documentation

grails.test
[Groovy] Class AbstractCliTestCase

java.lang.Object
  GroovyTestCase
      grails.test.AbstractCliTestCase

abstract class AbstractCliTestCase
extends GroovyTestCase

This abstract test case makes it easy to run a Grails command and query its output. It's currently configured via a set of system properties:


Property Summary
java.io.File outputDir

long timeout

 
Method Summary
void enterInput(java.lang.String input)

Allows you to provide user input for any commands that require it.

protected void execute(java.util.List command)

Executes a Grails command.

java.lang.String getOutput()

Returns the process output as a string.

java.io.File getWorkDir()

Returns the working directory for the current command.

void setOutput(java.lang.String output)

void setWorkDir(java.io.File dir)

protected void signalDone()

Signals any threads waiting on condition to inform them that the process output stream has been read.

protected void verifyHeader()

Checks that the output of the current command starts with the expected header, which includes the Grails version and the location of GRAILS_HOME.

int waitForProcess()

Waits for the current command to finish executing.

 

Property Detail

outputDir

java.io.File outputDir


timeout

long timeout


 
Method Detail

enterInput

void enterInput(java.lang.String input)
Allows you to provide user input for any commands that require it. In other words, you can run commands in interactive mode. For example, you could pass "app1" as the input parameter when running the "create-app" command.


execute

protected void execute(java.util.List command)
Executes a Grails command. The path to the Grails script is inserted at the front, so the first element of command should be the name of the Grails command you want to start, e.g. "help" or "run-app".
Parameters:
a - list of command arguments (minus the Grails script/executable).


getOutput

java.lang.String getOutput()
Returns the process output as a string.


getWorkDir

java.io.File getWorkDir()
Returns the working directory for the current command. This may be the base working directory or a project.


setOutput

void setOutput(java.lang.String output)


setWorkDir

void setWorkDir(java.io.File dir)


signalDone

protected void signalDone()
Signals any threads waiting on condition to inform them that the process output stream has been read. Should only be used by this class (not sub-classes). It's protected so that it can be called from the reader thread closure (some strange Groovy behaviour).


verifyHeader

protected final void verifyHeader()
Checks that the output of the current command starts with the expected header, which includes the Grails version and the location of GRAILS_HOME.


waitForProcess

int waitForProcess()
Waits for the current command to finish executing. It returns the exit code from the external process. It also dumps the process output into the "cli-tests/output" directory to aid debugging.


 

Groovy Documentation