3

I am doing POC on allure reporting.I created a Gradle project that has a test class with two @Test annotated methods.The same test class has @Step annotated method that has logger statements.This @Step annotated method is called from one of the @Test annotated methods.Upon running the tests,I do not see the logger info(present under @Step method) in allure result.

I have added needed dependencies and plugin in build.gradle.

content of build.gradle file.

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java Library project to get you started.
 * For more details take a look at the Java Libraries chapter in the Gradle
 * user guide available at https://docs.gradle.org/4.8.1/userguide/java_library_plugin.html
 */

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
    id "io.qameta.allure" version "2.8.1"
}

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'
    implementation 'io.qameta.allure:allure-testng:2.12.0'
    implementation 'org.testng:testng:6.9.9'
    compile('org.aspectj:aspectjweaver:1.9.4')
    compile 'org.slf4j:slf4j-api:1.7.25'
    compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.0.2'
    compile 'org.apache.logging.log4j:log4j-web:2.0.2'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:23.0'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
}

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

allure {
  version = '2.8.1'
  autoconfigure = true
  aspectjweaver = true
  useTestNG {
    version = '2.0-BETA20'
  }
}

my sample test code:

 public class SampleTestForAllureReport {

    public static Logger logger = LoggerFactory.getLogger(SampleTestForAllureReport.class);

    @Severity(SeverityLevel.BLOCKER)
    @Description("This is a sample test for printing welcome")
    @Test() 
    public void welcomeEvent()
    {   
        loggingSteps();
        System.out.println("WELCOME");
    }
    
    @Test()
    public void exitEvent()
    {
        System.out.println("EXIT");
    }
    
    
    @Step("logger for welcome test")
    public void loggingSteps()
    {
    logger.info("log for step1");
    
    }
}

allure result.

enter image description here

James Z
  • 12,209
  • 10
  • 24
  • 44
Rupa
  • 31
  • 1
  • how do you run your tests? If using IDE it requires to add aspectjweaver agent configuration to run configuration – Dmitry Baev Nov 08 '20 at 13:46

0 Answers0