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

Commit 8435d0b

Browse files
authored
Improve automated test output on failure (#1618)
* Changing assertion to make test fail, for testing purposes * Trying out a couple of changes to improve logging in the CI/CD * Trying out different options * Trying out different options * Trying out different options * Trying out different options * Trying out different options * Cleanup * Reverted changes for testing
1 parent 1039b4c commit 8435d0b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

rs-e2e/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ tasks.named('test') {
3636
task automatedTest(type: Test) {
3737
useJUnitPlatform()
3838
include '**/AutomatedTest.*'
39+
40+
testLogging {
41+
showStackTraces true
42+
exceptionFormat 'full'
43+
}
3944
}

rs-e2e/src/test/groovy/gov/hhs/cdc/trustedintermediary/rse2e/AutomatedTest.groovy

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AutomatedTest extends Specification {
1919
AssertionRuleEngine engine
2020
HapiHL7FileMatcher fileMatcher
2121
Logger mockLogger = Mock(Logger)
22+
List<String> loggedErrorsAndWarnings = []
2223

2324
def setup() {
2425
engine = AssertionRuleEngine.getInstance()
@@ -35,6 +36,13 @@ class AutomatedTest extends Specification {
3536
TestApplicationContext.register(LocalFileFetcher, LocalFileFetcher.getInstance())
3637
TestApplicationContext.injectRegisteredImplementations()
3738

39+
mockLogger.logWarning(_ as String, _ as Object) >> { String msg, Object args ->
40+
loggedErrorsAndWarnings << msg
41+
}
42+
mockLogger.logError(_ as String, _ as Exception) >> { String msg, Exception e ->
43+
loggedErrorsAndWarnings << msg
44+
}
45+
3846
FileFetcher azureFileFetcher = AzureBlobFileFetcher.getInstance()
3947
azureFiles = azureFileFetcher.fetchFiles()
4048

@@ -65,7 +73,8 @@ class AutomatedTest extends Specification {
6573

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

0 commit comments

Comments
 (0)