I want to construct where conditions based on setup data. But seems like where executes before setup method so I’m getting null object. I’m I right and how can I construct where data based on my setup data?
I want to construct where conditions based on setup data. But seems like where
Share
In short, you can’t. The
whereblock must run before thesetupblock/method for reasons discussed on the mailing list (http://forum.spockframework.org). However, awhereblock may refer to@Sharedvariables, which can be initialized directly or insetupSpec(). If necessary, you can write multiple spec classes with differentsetupSpec()methods and keep them all in the same file.Often, an alternative is to turn things around and use simple values (e.g. strings and numbers) in the
whereblock, from which more complex objects are constructed in thesetupblock.