October 22, 2024
Chicago 12, Melborne City, USA
java

Knowing all the cucumber tags related to a set of test cases before running them in Java


I am working on a test project in Java using Cucumber and JUnit5. I am running both API and UI test cases for a web application. For the API test cases we are using XSRF tokens as an extra layer of security (besides the usual bearer token). Today I am getting this token in the BeforeAll hook, because it can be used for all test cases in the execution, but I would like to generate this token only when there is at least one API test in the list of tests, it doesn’t make sense to generate it if I’m running only UI test cases.

The problem is this: how can I find out if there is at least one API test case in my test case list (that I am going to select using other tags) before the execution even begins?

The versions of the dependencies in my POM file:

<properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit-platform.version>1.11.2</junit-platform.version>
    <maven-surefire-junit-platform.version>3.5.1</maven-surefire-junit-platform.version>
    <selenium.version>4.25.0</selenium.version>
    <rest-assured.version>5.5.0</rest-assured.version>
    <log4j.version>2.24.1</log4j.version>
    <json.version>20240303</json.version>
    <cucumber.version>7.20.1</cucumber.version>
    <serenity.version>4.2.3</serenity.version>
    <maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
    <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
    <maven-surefire-plugin.version>3.5.1</maven-surefire-plugin.version>
    <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
    <maven-failsafe-plugin.version>3.5.1</maven-failsafe-plugin.version>
    <serenity-maven-plugin.version>4.2.3</serenity-maven-plugin.version>
</properties>



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video