|
|
|
Artima SuiteRunner |
Why |
Getting Started |
Tutorial |
Get Help |
Discuss |
Print |
Email |
First Page |
Previous |
Next
|
|
Sponsored Link •
|
Suite Execution by Overriding execute
|
Advertisement
|
execute
Class Suite's implementation of execute simply invokes executeTestMethods and
executeSubSuites, in that order. Suite's executeTestMethods implementation discovers
test methods through reflection and invokes them. Suite's executeSubSuites implementation
invokes execute on each of its sub-Suites. ScriptDrivenAccountSuite execute
method provides an alternate way to execute its own tests, but uses the default way of executing sub-Suites.
ScriptDrivenAccountSuite's execute method:
processLine, passing the Reporter, the String line,
and the line number. (The line number is sent so that it can be included in message Strings sent to the
Reporter.)
execute on each
sub-Suite.
Here's ScriptDrivenAccountSuite's execute method:
/**
* Execute this suite object.
*
* <P>This class's implementation of this method
* executes the test commands contained in the script file,
* then invokes <code>executeSubSuites</code> on itself,
* passing in the specified <code>Reporter<code>.
*
* @param reporter the <code>Reporter</code> to which results will be reported
* @exception NullPointerException if <CODE>reporter</CODE> is <CODE>null</CODE>.
*/
public void execute(Reporter reporter) {
if (reporter == null) {
throw new NullPointerException("reporter is null");
}
BufferedReader reader = null;
try {
FileInputStream fis = new FileInputStream(scriptFileName);
InputStreamReader isr = new InputStreamReader(fis);
reader = new BufferedReader(isr);
}
catch (FileNotFoundException e) {
// Runner will report this RuntimeException as with suiteAborted
// method invocation on the Reporter
throw new RuntimeException("Unable to open " + scriptFileName
+ ". " + e.getMessage());
}
try {
int lineNum = 1;
String line = reader.readLine();
while (line != null) {
if (isStopRequested()) {
return;
}
processLine(reporter, line, lineNum);
line = reader.readLine();
++lineNum;
}
}
catch (IOException e) {
// Runner will report this RuntimeException as with suiteAborted
// method invocation on the Reporter
throw new RuntimeException("Unable to read a line from script file "
+ scriptFileName + ". " + e.getMessage());
}
finally {
try {
reader.close();
}
catch (IOException e) {
throw new RuntimeException("Unable to close script file " +
scriptFileName + ". " + e.getMessage());
}
}
executeSubSuites(reporter);
}
|
Sponsored Links
|