org.specs.runner.SpecsFileRunner

class SpecsFileRunner

class SpecsFileRunner(path : String, specFilterPattern : String, susFilterPattern : String, exampleFilterPattern : String)

 extends SpecsFinder with Console


This class can be used to search for specifications on a given path and execute them.
Usage: object myFileRunner extends SpecsFileRunner(path, pattern)
Where path is a path to a directory containing scala files (it can be a glob: i.e. "dir*spec.scala") and pattern is a regular expression which is supposed to match an object name extending a Specification class named ".*Spec.*" The systems and examples can also be filtered by specifying patterns. These patterns can be passed as System properties, by specifying -Dsus="regexp" or -Dexample="regexp".


Source: SpecsFileRunner.scala(18)

 Constructors

def this(path : String, specFilterPattern : String)
short constructor with no filter for sus or examples
def this(path : String)
short constructor with the path only
def this(path : String, specFilterPattern : String, susFilterPattern : String, exampleFilterPattern : String)

 Fields

Debug val Debug Int Log
Error val Error Int Log
Info val Info Int Log
Warning val Warning Int Log
args var args
optional arguments to be used in the main method and which can be set from the code directly
Array[String] Reporter
asOneSpecification val asOneSpecification Boolean SpecsFinder
exampleFilter lazy val exampleFilter Pattern
examplePattern def examplePattern
[details]
return
- either the system property named "example" or the class attribute
String
failedAndErrorsOnly protected var failedAndErrorsOnly
this variable controls if ok examples should be printed
Boolean Reporter
level var level Int Log
pattern val pattern String SpecsFinder
productArity override def productArity Int SpecsFinder
productPrefix override def productPrefix String SpecsFinder
reportSpecs def reportSpecs
report the list of specifications held by the object mixing this trait
Reporter Reporter
specs override lazy val specs List[Specification]
stacktrace protected var stacktrace
this variable controls if stacktraces should be printed
Boolean Reporter
susFilter lazy val susFilter Pattern
susPattern def susPattern
[details]
return
- either the system property named "sus" or the class attribute
String
timer val timer
this timer uses java Calendar to compute hours, minutes, seconds and milliseconds
SimpleTimer Console

 Methods

!= final def !=(arg0 : Object) Boolean AnyRef
!= final def !=(arg0 : Any) Boolean Any
:: def ::(r : Reporter) List[Reporter] Reporter
== final def ==(arg0 : Any) Boolean Any
== final def ==(arg0 : Object) Boolean AnyRef
asInstanceOf final def asInstanceOf[T0] T0 Any
canRead def canRead(path : String)
[details]
return
- true if the file can be read
Boolean FileSystem
canWrite def canWrite(path : String)
[details]
return
- true if the file can be written
Boolean FileSystem
clone protected def clone Object AnyRef
collectSpecifications def collectSpecifications(result : Queue[String], filePath : String, pattern : String)
adds possible specification class names found in the file filePath
The specification pattern is: "\\s*object\\s*(" + pattern + ")\\s*extends\\s* [details]
*Spec.*\\s*\\{" This may be later extended to support other arbitrary patterns
param
pattern - a regular expression which is supposed to match an object name extending a Specification
path - a path to a directory containing scala files (it can be a glob: i.e. "dir*spec.scala")
Unit SpecificationsFinder
collectSpecs protected def collectSpecs(asOneSpecification : Boolean) List[Specification] SpecsFinder
copy def copy(input : InputStream, output : OutputStream)
Copy an input stream to an output stream [details]
param
output - output stream
input - input stream
Unit FileSystem
copyDir def copyDir(url : URL, dest : String, tagged : Tagged)
copy the content of a directory to another [details]
param
excluded - names for excluded files
dest - destination directory path
included - names for included files
url - url of the directory to copy
Unit FileSystem
copyDir def copyDir(src : String, dest : String, tagged : Tagged)
copy the content of a directory to another [details]
param
excluded - names for excluded files
dest - destination directory path
included - names for included files
path - path of the directory to copy
Unit FileSystem
copyDir def copyDir(url : URL, dest : String)
copy the content of a directory to another [details]
param
dest - destination directory path
url - url of the directory to copy
Unit FileSystem
copyDir def copyDir(src : String, dest : String)
copy the content of a directory to another [details]
param
dest - destination directory path
path - path of the directory to copy
Unit FileSystem
copyFile def copyFile(path : String, dest : String)
Copy the content of a directory to another [details]
param
dest - destination directory path
path - path of the file to copy
Unit FileSystem
copySpecResourcesDir def copySpecResourcesDir(src : String, outputDir : String)
Copy specs resources found either in the specs jar or in the classpath directories to an output directory [details]
Current limitations!! This only works if the jar holding the resources contains the word "specs".
param
outputDir - output directory where to copy the files to
src - name of the resource directory to copy
Unit FileSystem
createDir def createDir(path : String)
creates a directory for a given path
Boolean FileSystem
createFile def createFile(path : String)
creates a file for a given path [details]
Create the parent directory if necessary.
Unit FileWriter
createSpecification def createSpecification(className : String)
[details]
return
- None in case of an exception.
- a Specification object from a className if that class is a Specification class.
Tries to load the class name and cast it to a specification
Option[Specification] SpecificationsFinder
debug def debug(msg : => String)
prints the message if the log level is Debug
Unit Log
eq final def eq(arg0 : Object) Boolean AnyRef
equals override def equals(arg0 : Any) Boolean SpecsFinder
error def error(msg : => String)
prints the message if the log level is <= Error
Unit Log
exists def exists(path : String)
[details]
return
- true if the file exists
Boolean FileSystem
filePaths def filePaths(path : String)
[details]
param
path - glob expression, for example: ./dir*.xml
return
- the list of paths represented by the "glob" definition path
List[String] FileSystem
filter def filter(specification : Specification)
filter a specification [details]
return
- None if the resulting specification has no SUS or systems
Option[Specification]
filter def filter(sus : Sus)
filter a SUS [details]
return
- None if the resulting SUS has no examples
Option[Sus]
filter def filter(specifications : List[Specification])
filter a list of specifications
List[Specification]
filterExample def filterExample(example : Example)
filter one example [details]
return
- None if the example does not match the expected regular expression
Option[Example]
filterExamples def filterExamples(sus : Sus)
filter the examples of a SUS according to the regular expression [details]
return
- None if the resulting SUS has no examples
Sus
finalize protected def finalize Unit AnyRef
flush override def flush
flushes the content if necessary
Unit ConsoleOutput
getAbsolutePath def getAbsolutePath(path : String)
[details]
return
- the file absolute path
String FileSystem
getCanonicalPath def getCanonicalPath(path : String)
[details]
return
- the file canonical path
String FileSystem
getClass final def getClass Class[Object] AnyRef
getName def getName(path : String)
[details]
return
- the file name
String FileSystem
getParent def getParent(path : String)
[details]
return
- the file parent path
String FileSystem
getResourcesNamed def getResourcesNamed(name : String)
Return urls of the resources containing the name "name" from this ClassLoader and the System classLoader [details]
param
name - name of the resource to find
return
- a list of URL
List[URL] FileSystem
getWriter def getWriter(path : String)
The getWriter function can be overriden to provide a mock writer writing to the console for example [details]
return
- a Writer object opened on the file designated by path
Writer FileWriter
globToPattern def globToPattern(glob : String)
[details]
return
- the regular expression equivalent to a glob pattern (see the specs for examples)
String FileSystem
hashCode override def hashCode Int SpecsFinder
info def info(msg : => String)
prints the message if the log level is <= Info
Unit Log
isAbsolute def isAbsolute(path : String)
[details]
return
- true if the file is absolute
Boolean FileSystem
isDir def isDir(path : String)
[details]
return
- true if the File represented by this path is a directory
Boolean FileSystem
isDirectory def isDirectory(path : String)
[details]
return
- true if the file is a directory
Boolean FileSystem
isFile def isFile(path : String)
[details]
return
- true if the file is a file
Boolean FileSystem
isHidden def isHidden(path : String)
[details]
return
- true if the file is hidden
Boolean FileSystem
isInstanceOf final def isInstanceOf[T0] Boolean Any
listFiles def listFiles(path : String)
[details]
return
- the files of that directory
List[String] FileSystem
main def main(arguments : Array[String])
Main method for the Reporter trait [details]
It first agregates all arguments: passed to the class and passed from the command line. Then it calls the reportSpecs method and exit the System with the appropriate error code, depending on the specification success or not.
Unit Reporter
mkdirs def mkdirs(path : String)
creates a new directory
Boolean FileWriter
ne final def ne(arg0 : Object) Boolean AnyRef
notify final def notify Unit AnyRef
notifyAll final def notifyAll Unit AnyRef
packageName def packageName(path : String)
[details]
return
- the package declaration at the beginning of a file
Option[String] SpecificationsFinder
printStackTrace def printStackTrace(t : Throwable)
prints stacktraces
Unit Output
printStats def printStats(sus : Sus, padding : String)
prints the statistics for a sus
Unit OutputReporter
printStats def printStats(stat : (Int, Int, Int, Int, Int), padding : String)
prints the statistics for a specification
Unit OutputReporter
printSus def printSus(sus : Sus, padding : String)
prints one sus specification
Unit OutputReporter
printf def printf(format : String, args : Any*)
prints several objects according to a format string (see Console [details]
printf)
Unit ConsoleOutput
println def println(m : Any)
prints an object with a newline
Unit ConsoleOutput
productElement override def productElement(arg0 : Int) Any SpecsFinder
readFile def readFile(path : String)
reads the content of a file [details]
param
path - the path of the file to read
return
- the content of the file at path
String FileReader
removeDir def removeDir(path : String)
deletes the directory and all directory contents at the specified path and return the parent path of that directory
String FileSystem
report override def report(specs : Seq[Specification])
override the parent method for arguments setting and call the local report method with no padding to being with
OutputReporter OutputReporter
report def report(specs : Seq[Specification], padding : String)
reports a list of specifications with a given space separator to display before the results [details]

This method may be called recursively by the reportSpec method if a specification has subSpecifications, hence the padding will be incremented
OutputReporter OutputReporter
reportExample def reportExample(example : Example, padding : String)
reports one example: + if it succeeds, x if it fails, its description, its failures or errors
Unit OutputReporter
reportExamples def reportExamples(examples : Iterable[Example], padding : String)
reports a list of examples and indent subexamples if there are some
Unit OutputReporter
reportSpec def reportSpec(spec : Specification, padding : String)
reports a specification with a given space separator to display before the results [details]

This method may be called recursively by the reportSpec method if a specification has subSpecifications, hence the padding will be incremented
OutputReporter OutputReporter
reportSus def reportSus(sus : Sus, padding : String)
reports one sus results: print the sus specifications, then the statistics
Unit OutputReporter
reportSystems def reportSystems(systems : Iterable[Sus], padding : String)
reports the sus results [details]
If there are more than one, then report stats for each else just print the specification of the sus, the parent specification will display the total for that sus
Unit OutputReporter
resetOptions def resetOptions
reset all options
Reporter Reporter
setFailedAndErrorsOnly def setFailedAndErrorsOnly
allow subclasses to remove the ok and skipped examples
Reporter Reporter
setNoStacktrace def setNoStacktrace
allow subclasses to remove the stacktrace display
Reporter Reporter
specificationNames def specificationNames(path : String, pattern : String)
[details]
param
pattern - a regular expression which is supposed to match an object name extending a Specification
path - a path to a directory containing scala files (it can be a glob: i.e. "dir*spec.scala")
return
- specification names by scanning files and trying to find specifications declarations
List[String] SpecificationsFinder
stats def stats(example : Example)
[details]
return
- the number of examples, expectations, failures and errors for an example by collecting those numbers on this example and on sub-examples
(Int, Int, Int, Int, Int) OutputReporter
stats def stats(spec : Specification)
[details]
return
- the number of examples, expectations, failures and errors for a specification by collecting those numbers on sub-specifications and systems
(Int, Int, Int, Int, Int) OutputReporter
stats def stats(sus : Sus)
[details]
return
- the number of examples, expectations, failures and errors for a sus by collecting those numbers on examples
(Int, Int, Int, Int, Int) OutputReporter
synchronized final def synchronized[T0](arg0 : T0) T0 AnyRef
toAddableTuple implicit def toAddableTuple(t1 : (Int, Int, Int, Int, Int))
utility implicit definition to be able to add tuples
AddableTuple OutputReporter
toString override def toString String SpecsFinder
unjar def unjar(path : String, dest : String)
Unjar the jar (or zip file) specified by "path" to the "dest" directory [details]
param
dest - destination directory path
path - path of the jar file
Unit FileSystem
unjar def unjar(path : String, dirPath : String, regexFilter : String)
Unjar the jar (or zip file) specified by "path" to the "dest" directory [details]
Filters files which shouldn't be extracted with a regular expression.
param
dest - destination directory path
regexFilter - regular expression filtering files which shouldn't be extracted
path - path of the jar file
Unit FileSystem
wait final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait final def wait(arg0 : Long) Unit AnyRef
wait final def wait Unit AnyRef
warning def warning(msg : => String)
prints the message if the log level is <= Warning
Unit Log
write def write(path : String)(function : (Writer) => Unit)
writes some content to a file and take care of closing the file [details]

Usage:

   write("./dir/hello.txt") { out =>
     out.write("content")
   }
   
param
path - path of the file to write
Unit FileWriter
writeFile def writeFile(path : String, content : => String)
writes some content to a file [details]
param
path - path of the file to read @content content of the file to write
Unit FileWriter
Copyright (c) 2007-2009. All Rights Reserved.