consensusj
consensusj copied to clipboard
Use annotations to mark test Specs and/or features as @RegTest or not.
Using annotations and an external Spock configuration file, we should be able to mark test Specs or feature tests as requiring RegTest mode or not.
A test that has a @RegTest annotation would only run if the current functional/integration test configuration was running against a server in RegTest mode.
See Spocklight: Including or Excluding Specifications Based On Annotations by @mrhaki.
So for example, the entire class BitcoinStepwiseSpec would have a @RegTest annotation. Whereas, BitcoinSpec would only user @RegTest on feature test methods that used generateBlock().
@dexX7 Obviously this would be useful for Omni testing, as well.
This is very nice! Potentially, this could also be used to get rid of the setupSpec -> !commandExists -> throw AssumptionViolatedException workarounds?
Well, there's another @mrhaki Spocklight article that may have a better solution for that case: Spocklight: Only Run Specs Based On Conditions.
At least out of the box it's not as simple as adding:
@Requires({ commandExists('abc') })
While it works with simple expressions such as { true }, I assume this is because I'm trying to access the RPC client.
If the method commandExists is a static method it should work in they way you described it.