Gauge Tags from my gauge gradle task is not being passed to beforespec

354 Views Asked by At

I have an issue where tags from my gauge gradle task is not being passed to beforespec whereas the the tags are passed to spec files Any idea what is the issue?

I'm in Gauge version: 0.9.1 Plugins html-report (3.1.0) java (0.6.2)

gradle gauge task :

task runTestsInQA(type: GaugeTask) {
  doFirst {
    println 'Running tests for the V1 in QA environment...'
    gauge {
      specsDir = 'specs'
      tags = 'V1'
      env = 'qa'
      additionalFlags = '--verbose'
    }
  }
}

_ My beforespec code:

@beforespec(tags = "V1")
public void beforeSpec(ExecutionContext context)
{
  System.out.println("Tags in scenario "+context.getAllTags());
}

Here, print statement is throwing null array [ ]

1

There are 1 best solutions below

0
On

This gist contains an example project with gauge + java + gradle.

In your case, note that the BeforeSpec hook is a tagged execution hook, so it will get executed only when the respective tags are passed.

Also note that if you wish to get tags for a scenario, you are better off using the BeforeScenario hook, since you can then get all the tags (scenarios inherit spec tags).