org.spockframework.runtime.extension.builtin
Class JUnitFixtureMethodsExtension

java.lang.Object
  extended by org.spockframework.runtime.extension.builtin.JUnitFixtureMethodsExtension
All Implemented Interfaces:
IGlobalExtension

public class JUnitFixtureMethodsExtension
extends java.lang.Object
implements IGlobalExtension

Adapts the JUnit Before, After, BeforeClass and AfterClass fixture mechanism to Spock.

The method signature requirements that JUnit has for fixture methods apply exactly to Spock as well. That is, fixture methods must return void, must take no arguments and must be public. Moreover, Before and After fixture methods must be instance methods while BeforeClass and AfterClass fixture methods must be static. Any methods that do not meet the requirements will be silently ignored.

BeforeClass fixture methods will be executed once before any feature methods or Before or setup() methods, and before the setupSpec() method (if present). Inheritance semantics are identical to setupSpec(), i.e. methods are executed for each class in the hierarchy in turn from parent to child.

Before fixture methods will be executed before every feature method and before the setup() method (if present). Inheritance semantics are identical to setup(), i.e. methods are executed for each class in the hierarchy in turn from parent to child.

After fixture methods will be executed after every feature method and after the cleanup() method (if present). Inheritance semantics are identical to cleanup(), i.e. methods are executed for each class in the hierarchy in turn from child to parent.

AfterClass fixture methods will be executed once after all feature methods and after After and cleanup() methods, and after the cleanupSpec() method (if present). Inheritance semantics are identical to cleanupSpec(), i.e. methods are executed for each class in the hierarchy in turn from child to parent.

The execution order of fixture methods of the same type withing the same class is undefined (as it is with JUnit).

Author:
Luke Daley

Constructor Summary
JUnitFixtureMethodsExtension()
           
 
Method Summary
 void visitSpec(SpecInfo spec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JUnitFixtureMethodsExtension

public JUnitFixtureMethodsExtension()
Method Detail

visitSpec

public void visitSpec(SpecInfo spec)
Specified by:
visitSpec in interface IGlobalExtension


Copyright © 2013. All rights reserved