java - Good practice when using logback, TestNG on a continuous integration server -
java - Good practice when using logback, TestNG on a continuous integration server -
we're using logback , testng our project. logback set output both console , file, trace level when we're doing tests (set in logback-test.xml
file).
now, there 2 issues. first, when running on ci server (teamcity), 700+mb buildlog file, waste of space (there log file already), , overloads browser. second, can't assertion errors printed in log. because these caught testng, show in teamcity's ui, not in file logs.
what should approaches here? i'm thinking logging @ info level on console, if run under teamcity, , trace otherwise. accomplish using filter, controlled via environment variable. sec issue, still don't have idea.
tia, nikola
in order assertionerror
s printed in file logs, ended implementing testng's itestlistener
:
public class listenerlogger implements itestlistener { private static final logger log = loggerfactory.getlogger(listenerlogger.class); @override public void onteststart(itestresult result) { log.info("starting {}.{} parameters {}", result.gettestclass().getname(), result.gettestname(), result.getparameters()); } @override public void ontestsuccess(itestresult itestresult) { log.info("test successful"); } // belongs itestlistener , execute on event of fail test public void ontestfailure(itestresult result) { log.error("test failed!", result.getthrowable()); } ... }
and added pom.xml
of project have under ci:
<dependency> <groupid>my.awesome.project</groupid> <artifactid>ci-helper</artifactid> <version>1.0.1</version> <scope>test</scope> </dependency>
java teamcity testng logback
Comments
Post a Comment