cucumber tags based on maven profile

≯℡__Kan透↙ 提交于 2020-01-02 19:12:01

问题


I am trying to run specific Gherkin scenarios based on the variable @tags(if it is possible). For example, if my profile is "dev" I want to run scenario 1 and if profile is "qa" I want to run scenario 2. I can get the profile value in my java class. I can also pass the tags in the command line and run it as mentioned here. But that is not something I am looking for. For example:

@QA
Scenario:I do x and check y
  Given I do abc
  Then the response is 200
@DEV
Scenario:I do y and check x
  Given I do cde
  Then the response is 500

I am getting the profile value in java class as

System.getProperty("myprofile");

How can I set the tags for cucumber based on my profile so that I can run specific test in specific environment? Basically, I do not want to pass the tags in command line rather want to set it based on my profile. Would it be possible? If not, what would be the best way?


回答1:


I achieved this using maven profile. In each profile, set the cucumber options as

<profiles>
  <profile>
   <id>development</id>
   <properties>
      <cucumber.options>
        --tags @myTags
      </cucumber.options>
   <properties>
   </profile>
   ............
</profiles>

Then pass that as System Property variable in the build plugin as

<build>
  <plugins>
   <plugin>
      <configuration>
        <systemPropertyVariables>
          <cucumber.options>${cucumber.options}</cucumber.options>
        </systemPropertyVariables>
      </configuration>
   <plugin>
  </plugins>
</build>


来源:https://stackoverflow.com/questions/45703426/cucumber-tags-based-on-maven-profile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!