When I run my test with Maven command, these logs are not printed out. Could you explain why?
@RunWith(Cucumber.class)
@CucumberOptions(features= "src/test/resources/features/dhlcj", glue="com.dhl.gaqcjqa.fsApi.steps")
public class TestRunnerFsApi extends AbstractTestNGCucumberTests {
static {
Log.info("--------------------------------------------");
Log.info("S T A R T ");
UrlFactory.loadAllResources();
Log.info("E N D ");
Log.info("--------------------------------------------");
int processors = Runtime.getRuntime().availableProcessors();
Log.info("CPU cores: " + processors);
Log.info("--------------------------------------------");
}
}
Instead I get some unnecessary info like:
[2020-06-25 21:59:18] [INFO] Loaded: environments/dev >> 1
The first issue that I have found in your code is you are using both Junit as well as testng in your runner. Please remove the @Runwith(Cucumber.class) in order to use only testNG. I do not know which dependency you are using for the logging in your project but the following dependency I have used in order to log the messages.
Maven Dependency:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
Cucumber Runner:
@CucumberOptions(eatures = { "src/test/resources/features" }, glue = { "com.github.frostyaxe.cucumber.stepdefs" } )
public class TestRunner extends AbstractTestNGCucumberTests {
private static Logger log = Logger.getLogger(TestRunner.class);
static {
log.addAppender(new ConsoleAppender(new PatternLayout()));
log.info("--------------------------------------------");
log.info("S T A R T ");
log.info("E N D ");
log.info("--------------------------------------------");
int processors = Runtime.getRuntime().availableProcessors();
log.info("CPU cores: " + processors);
log.info("--------------------------------------------");
}
Output:
--------------------------------------------
S T A R T
E N D
--------------------------------------------
CPU cores: 8
--------------------------------------------