Last active
August 6, 2021 15:42
-
-
Save djangofan/4747929 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
apply plugin: 'eclipse' | |
ext { | |
projVersion = '1.0' | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+' | |
compile group: 'junit', name: 'junit', version: '4.+' | |
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+' | |
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+' | |
} | |
task testCacheSuite(type: Test) { | |
// task to run a single JUnit test suite | |
systemProperty 'logback.configurationFile', 'logback.xml' | |
include '**/SuiteOfTests.class' | |
testReportDir = file("${reporting.baseDir}/SuiteOfTests") | |
testResultsDir = file("${buildDir}/test-results/SuiteOfTests") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see build.gradle for imports | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import ch.qos.logback.classic.LoggerContext; | |
import ch.qos.logback.core.util.StatusPrinter; | |
... | |
public abstract class Utilities { | |
public static final Logger logger = LoggerFactory.getLogger( "AnyUniqueStringHere" ); | |
... | |
public static void printLoggerState() { | |
// print internal state | |
LoggerContext lc = (LoggerContext)LoggerFactory.getILoggerFactory(); | |
StatusPrinter.print(lc); | |
} | |
... | |
} | |
public class Test extends Utilities { | |
@Test | |
public myTest { | |
printLoggerState(); // to console | |
logger.info("Hello World"); | |
} | |
... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration> | |
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
<!-- encoders are assigned the type | |
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
<encoder> | |
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern> | |
</encoder> | |
</appender> | |
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | |
<file>junit.log</file> | |
<append>false</append> | |
<!-- encoders are assigned the type | |
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | |
<encoder> | |
<pattern>%-4r %-5level %logger{35}: %msg%n</pattern> | |
</encoder> | |
</appender> | |
<root level="INFO"> | |
<appender-ref ref="FILE" /> | |
<appender-ref ref="STDOUT" /> | |
</root> | |
<!-- We want error logging from this logger to go to an extra appender | |
It still inherits CONSOLE STDOUT from the root logger --> | |
<logger name="junit" level="INFO"> | |
<appender-ref ref="STDOUT" /> | |
</logger> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think you forgot to attach the SuiteOfTests.class file?