Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Improve automated test output on failure #1618

Merged
merged 9 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions rs-e2e/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ tasks.named('test') {
task automatedTest(type: Test) {
useJUnitPlatform()
include '**/AutomatedTest.*'

testLogging {
showStackTraces true
exceptionFormat 'full'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AutomatedTest extends Specification {
AssertionRuleEngine engine
HapiHL7FileMatcher fileMatcher
Logger mockLogger = Mock(Logger)
List<String> loggedErrorsAndWarnings = []

def setup() {
engine = AssertionRuleEngine.getInstance()
Expand All @@ -35,6 +36,13 @@ class AutomatedTest extends Specification {
TestApplicationContext.register(LocalFileFetcher, LocalFileFetcher.getInstance())
TestApplicationContext.injectRegisteredImplementations()

mockLogger.logWarning(_ as String, _ as Object) >> { String msg, Object args ->
loggedErrorsAndWarnings << msg
}
mockLogger.logError(_ as String, _ as Exception) >> { String msg, Exception e ->
loggedErrorsAndWarnings << msg
}

FileFetcher azureFileFetcher = AzureBlobFileFetcher.getInstance()
azureFiles = azureFileFetcher.fetchFiles()

Expand Down Expand Up @@ -65,7 +73,8 @@ class AutomatedTest extends Specification {

then:
rulesToEvaluate.collect { it.name }.isEmpty() //Check whether all the rules in the assertions file have been run
0 * mockLogger.logError(_ as String, _ as Exception)
0 * mockLogger.logWarning(_ as String)
if (!loggedErrorsAndWarnings.isEmpty()) {
throw new AssertionError("Unexpected errors and/or warnings were logged:\n- ${loggedErrorsAndWarnings.join('\n- ')}")
}
}
}