forked from scream3r/java-simple-serial-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Shows method names for tests #156 * Removes slf4j from unit tests * Fully switches to log4j for test logging * Maven-like Log4j configuration for test execution * Fixes Ubuntu pipeline --------- Co-authored-by: Mateusz Pietryga <pietryga.m@gmail.com>
- Loading branch information
1 parent
b9b6b25
commit 56f58bb
Showing
9 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package jssc.junit.rules; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.logging.log4j.MarkerManager; | ||
import org.junit.Rule; | ||
import org.junit.rules.TestWatcher; | ||
import org.junit.runner.Description; | ||
|
||
/** | ||
* Adds the method name to the JUnit logs, useful for debugging | ||
*/ | ||
public class DisplayMethodNameRule { | ||
@Rule | ||
public TestWatcher methodWatcher = new TestWatcher() { | ||
@Override | ||
protected void starting(Description description) { | ||
Logger log = LogManager.getLogger(description.getTestClass()); | ||
log.info(MarkerManager.getMarker("MethodName"), description.getMethodName()); | ||
} | ||
}; | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Logging settings for unit tests | ||
|
||
# The root logger with appender name | ||
rootLogger=DEBUG,STDOUT,TESTNAME | ||
|
||
# Assign STDOUT a valid appender & define its layout | ||
appender.console.name=STDOUT | ||
appender.console.type=Console | ||
appender.console.layout.type=PatternLayout | ||
appender.console.layout.pattern=[%highlight{%p}{INFO=blue}] [%c{1}] %m%n | ||
|
||
# Make logs for Junit4 method names look like maven | ||
appender.testName.name=TESTNAME | ||
appender.testName.type=Console | ||
appender.testName.layout.type=PatternLayout | ||
appender.testName.layout.pattern=[%highlight{%p}{INFO=blue}] Running %c.%highlight{%m}{FATAL=bold,white, ERROR=bold,white, WARN=bold,white, INFO=bold,white, DEBUG=bold,white, TRACE=bold,white}%n | ||
appender.testName.filter.1.type=MarkerFilter | ||
appender.testName.filter.1.marker=MethodName | ||
appender.console.filter.1.type=MarkerFilter | ||
appender.console.filter.1.marker=MethodName | ||
appender.console.filter.1.onMatch=DENY | ||
appender.console.filter.1.onMismatch=ACCEPT |