'How to use allure annotations in code directly?

I am writing selenium based browser tests , I would like to implement @Step annotation inside page object models which are in src/java folder.

When doing that I am not able to use / import @Step annotation ( i have gradle ktls plugin installed )

This is code which is part of page object model under src/java

    @Step("Find flow based on file name : {fileName}")
    public DataTable findByFileName(String fileName) {
        selectedElement= dataTableElementList.stream()
                .filter(dataTableElement -> fileName.equals(dataTableElement.getFile_name()))
                .findFirst()
                .orElse(null);
        return this;
    }

Overall idea is to annotate all steps which are taken in page object model methods and then use it to create step-by-step annotated report.

My kotlin build

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
}

tasks.existing(Wrapper::class) {
    gradleVersion = "4.10.2"
    distributionType = Wrapper.DistributionType.ALL
}

description = "LM"
group = "ru.lm"
version = version

plugins {
    java
    id("io.qameta.allure") version "2.6.0"
    id("io.freefair.lombok") version "5.3.0"
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

val allureVersion = "2.9.0"

allure {

    version = allureVersion
    useTestNG {
        version = allureVersion
    }
    downloadLink = "https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/$allureVersion/allure-commandline-$allureVersion.zip"
}

dependencies {
    implementation("org.testng:testng:6.14.3")
    implementation("com.fasterxml.jackson.core:jackson-annotations:2.12.3")
    implementation("com.codeborne:selenide:6.2.1")
    implementation("net.andreinc:mockneat:0.4.8")
    implementation("com.konghq:unirest-java:4.0.0-RC2")
    implementation("io.rest-assured:rest-assured:4.5.0")
    implementation("org.hamcrest:hamcrest-all:1.3")
    implementation("org.apache.logging.log4j:log4j-api:2.16.0")
    implementation("org.apache.logging.log4j:log4j-core:2.16.0")
    testImplementation("org.slf4j:slf4j-simple:2.0.0-alpha6")
}

tasks.named<Test>("test") {
    useTestNG(closureOf<TestNGOptions> {
        suites("src/test/resources/workflow.xml")
    })
}

tasks.withType(JavaCompile::class) {
    options.encoding = "UTF-8"
}

repositories {
    mavenLocal()
    jcenter()
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source