Skip to content

Commit 6bb92a9

Browse files
committed
Merge branch 'release/1.7.0'
2 parents 450dc74 + 9bb9b50 commit 6bb92a9

37 files changed

+809
-112
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
key: v1-dependencies-{{ checksum "build.gradle" }}
2424
- run:
2525
name: Run tests
26-
command: GRADLE_OPTS="-Xms256m -Xmx2048m" ./gradlew build --no-daemon
26+
command: GRADLE_OPTS="-Xms256m -Xmx2048m" ./gradlew build --no-daemon --scan
2727
- run:
2828
name: Code coverage
29-
command: GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew jacocoTestReport coveralls --no-daemon
29+
command: GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew jacocoTestReport coveralls --no-daemon --scan
3030
- run:
3131
name: Save reports
3232
command: |
@@ -68,7 +68,7 @@ jobs:
6868
- run:
6969
name: Publish plugin
7070
command:
71-
GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew clean publishPlugins --no-daemon
71+
GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew clean publishPlugins --no-daemon --scan
7272
-Pgradle.publish.key=${GRADLE_PUBLISH_KEY}
7373
-Pgradle.publish.secret=${GRADLE_PUBLISH_SECRET}
7474

CHANGELOG.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
# Change Log
22

3-
## [v1.6.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v1.6.0) (2018-11-20)
3+
## [v1.7.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v1.7.0) (2019-05-29)
4+
[Full Changelog](https://github.com/radarsh/gradle-test-logger-plugin/compare/v1.6.0...v1.7.0)
5+
6+
**Closed issues:**
7+
8+
- Not enough details about exception thrown by the test. [\#118](https://github.com/radarsh/gradle-test-logger-plugin/issues/118)
9+
- NoSuchMethodError: org.fusesource.jansi.Ansi.fgGreen\(\)Lorg/fusesource/jansi/Ans [\#116](https://github.com/radarsh/gradle-test-logger-plugin/issues/116)
10+
- Mocha on dark terminals [\#115](https://github.com/radarsh/gradle-test-logger-plugin/issues/115)
11+
- Add support for @Nested and @DisplayName [\#106](https://github.com/radarsh/gradle-test-logger-plugin/issues/106)
12+
- Get rid of logs original test logs [\#105](https://github.com/radarsh/gradle-test-logger-plugin/issues/105)
13+
- Prints corrupted json [\#104](https://github.com/radarsh/gradle-test-logger-plugin/issues/104)
14+
- Bad encoding on standard and mocha themes when printing to Eclipse's console [\#92](https://github.com/radarsh/gradle-test-logger-plugin/issues/92)
15+
- Testsuite fatal error output not shown [\#89](https://github.com/radarsh/gradle-test-logger-plugin/issues/89)
416

17+
**Merged pull requests:**
18+
19+
- Show full stacktraces [\#119](https://github.com/radarsh/gradle-test-logger-plugin/pull/119) ([radarsh](https://github.com/radarsh))
20+
- Improve Windows build stability [\#117](https://github.com/radarsh/gradle-test-logger-plugin/pull/117) ([radarsh](https://github.com/radarsh))
21+
- Show output from before System.exit\(5\) was called [\#113](https://github.com/radarsh/gradle-test-logger-plugin/pull/113) ([radarsh](https://github.com/radarsh))
22+
- Configure build-scan plugin [\#112](https://github.com/radarsh/gradle-test-logger-plugin/pull/112) ([aalmiray](https://github.com/aalmiray))
23+
- Use classDisplayName for friendlier suite names [\#109](https://github.com/radarsh/gradle-test-logger-plugin/pull/109) ([radarsh](https://github.com/radarsh))
24+
- Fix double escaping of brackets [\#108](https://github.com/radarsh/gradle-test-logger-plugin/pull/108) ([radarsh](https://github.com/radarsh))
25+
26+
## [v1.6.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v1.6.0) (2018-11-20)
527
[Full Changelog](https://github.com/radarsh/gradle-test-logger-plugin/compare/v1.5.0...v1.6.0)
628

729
**Implemented enhancements:**

README.md

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Scroll down for more themes and customisation options or visit the [screenshots
2525

2626
```groovy
2727
plugins {
28-
id 'com.adarshr.test-logger' version '1.6.0'
28+
id 'com.adarshr.test-logger' version '1.7.0'
2929
}
3030
```
3131

@@ -39,7 +39,7 @@ buildscript {
3939
}
4040
}
4141
dependencies {
42-
classpath 'com.adarshr:gradle-test-logger-plugin:1.6.0'
42+
classpath 'com.adarshr:gradle-test-logger-plugin:1.7.0'
4343
}
4444
}
4545
@@ -57,8 +57,12 @@ The following shows the complete default configuration applied when you configur
5757
testlogger {
5858
theme 'standard'
5959
showExceptions true
60+
showStackTraces true
61+
showFullStackTraces false
62+
showCauses true
6063
slowThreshold 2000
6164
showSummary true
65+
showSimpleNames false
6266
showPassed true
6367
showSkipped true
6468
showFailed true
@@ -164,6 +168,17 @@ testlogger {
164168
}
165169
```
166170

171+
### Show simple names
172+
173+
If you don't like seeing long, fully-qualified class names being used for displaying the test suite names, you can choose to
174+
show only [simple names](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getSimpleName--) by setting the below flag to true.
175+
176+
```groovy
177+
testlogger {
178+
showSimpleNames true
179+
}
180+
```
181+
167182
### Show standard streams
168183

169184
The display of standard output and error streams alongside the test logs can be controlled using the below configuration.
@@ -212,6 +227,35 @@ testlogger {
212227
By default all the above three flags are turned on. If you have chosen to display standard streams by setting
213228
`showStandardStreams` flag to `true`, any output produced by filtered out tests will not be displayed.
214229

230+
### Relationship between `testlogger` and `Test.testLogging`
231+
232+
Where possible, the plugin's `testlogger` extension tries to react to equivalent properties of Gradle's `Test.testLogging`
233+
extension. However, if a value is explicitly configured under the `testlogger` extension, the plugin __does not__ react to the
234+
corresponding property of `Test.testLogging`. The below table demonstrates this in more detail.
235+
236+
| Property | `Test.testLogging` value | `testlogging` value | Effective value |
237+
|---------------------------|---------------------------------------|------------------------|---------------- |
238+
| `showStandardStreams` | `true` | not configured | `true` |
239+
| `showStandardStreams` | `true` | `false` | `false` |
240+
| `showStandardStreams` | `false` | `true` | `true` |
241+
| `showExceptions` | `true` | not configured | `true` |
242+
| `showExceptions` | `true` | `false` | `false` |
243+
| `showExceptions` | `false` | `true` | `true` |
244+
| `showStackTraces` | `true` | not configured | `true` |
245+
| `showStackTraces` | `true` | `false` | `false` |
246+
| `showStackTraces` | `false` | `true` | `true` |
247+
| `showFullStackTraces` | `testLogging.exceptionFormat = FULL` | not configured | `true` |
248+
| `showFullStackTraces` | `testLogging.exceptionFormat = SHORT` | not configured | `false` |
249+
| `showFullStackTraces` | `testLogging.exceptionFormat = FULL` | `false` | `false` |
250+
| `showFullStackTraces` | `testLogging.exceptionFormat = SHORT` | `true` | `true` |
251+
| `showCauses` | `true` | not configured | `true` |
252+
| `showCauses` | `true` | `false` | `false` |
253+
| `showCauses` | `false` | `true` | `true` |
254+
255+
In other words, an explicitly configured `testlogger` property, despite it being `false`, takes precedence over any
256+
value of `Test.testLogging`.
257+
258+
215259
## FAQ
216260

217261
### Does it work on Windows?
@@ -233,15 +277,6 @@ Yes. You will need to switch to a suitable parallel theme though. This can be on
233277
[`maxParallelForks`](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html#org.gradle.api.tasks.testing.Test:maxParallelForks)
234278
greater than 1. They achieve this by sacrificing the ability to group tests and thus some readability is lost.
235279

236-
### How are `testlogger` and `Test.testLogging` related?
237-
238-
Until recently, they were unrelated. While this plugin's `testlogger` has many properties named identical to the ones in Gradle's
239-
`Test.testLogging`, to a large extent, they are kept isolated by design.
240-
241-
However, as of this writing `testlogger.showStandardStreams` property has been made to react to `testLogging.showStandardStreams`
242-
property as long as one doesn't configure a value for `testlogger.showStandardStreams`. If a value is configured for
243-
`testlogger.showStandardStreams` (even if it is `false`), the plugin ignores `testLogging.showStandardStreams` altogether.
244-
245280
### Can this plugin co-exist with junit-platform-gradle-plugin?
246281

247282
Due to certain unknown reasons, `junit-platform-gradle-plugin` is incompatible with `gradle-test-logger-plugin`. If you are still

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ buildscript {
55
}
66

77
plugins {
8+
id 'com.gradle.build-scan' version '1.16'
89
id 'groovy'
910
id 'java-gradle-plugin'
1011
id 'maven-publish'
@@ -14,6 +15,11 @@ plugins {
1415
id 'com.github.kt3k.coveralls' version '2.8.2'
1516
}
1617

18+
buildScan {
19+
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
20+
termsOfServiceAgree = 'yes'
21+
}
22+
1723
def thisPlugin =
1824
new GroovyScriptEngine(file('src/main/groovy').absolutePath, this.class.classLoader)
1925
.loadScriptByName('com/adarshr/gradle/testlogger/TestLoggerPlugin.groovy')
@@ -76,6 +82,10 @@ test {
7682
testClassesDirs += sourceSets.functionalTest.output.classesDirs
7783
classpath += sourceSets.functionalTest.runtimeClasspath
7884
systemProperty 'file.encoding', 'UTF-8'
85+
86+
// testLogging {
87+
// exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
88+
// }
7989

8090
testlogger {
8191
theme 'mocha'

gradle.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
version=1.6.0
1+
version=1.7.0
22
group=com.adarshr
3+
4+
org.gradle.daemon = true
5+
org.gradle.caching = true
6+
org.gradle.parallel = true

src/main/groovy/com/adarshr/gradle/testlogger/TestDescriptorWrapper.groovy

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,23 @@ class TestDescriptorWrapper {
2222
escape(testDescriptor.className)
2323
}
2424

25+
@CompileDynamic
26+
String getClassDisplayName() {
27+
def className = testDescriptor.className
28+
def classDisplayName = testDescriptor.properties.classDisplayName as String
29+
def useClassDisplayName = classDisplayName && classDisplayName != className && !className.endsWith(classDisplayName)
30+
31+
if (testLoggerExtension.showSimpleNames) {
32+
className = className.substring(className.lastIndexOf('.') + 1)
33+
className = className.substring(className.lastIndexOf('$') + 1)
34+
}
35+
36+
escape(useClassDisplayName ? classDisplayName : className)
37+
}
38+
2539
@CompileDynamic
2640
String getDisplayName() {
27-
escape(testDescriptor.properties.displayName ?: name)
41+
escape(testDescriptor.properties.displayName ?: testDescriptor.name as String)
2842
}
2943

3044
String getSuiteKey() {

src/main/groovy/com/adarshr/gradle/testlogger/TestLoggerExtension.groovy

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ import org.gradle.api.tasks.testing.logging.TestLogging
99
import static com.adarshr.gradle.testlogger.theme.ThemeType.PLAIN
1010
import static com.adarshr.gradle.testlogger.theme.ThemeType.STANDARD
1111
import static org.gradle.api.logging.configuration.ConsoleOutput.Plain
12+
import static org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
1213

1314
@CompileStatic
1415
@SuppressWarnings("GroovyUnusedDeclaration")
1516
class TestLoggerExtension {
1617

1718
ThemeType theme = STANDARD
1819
boolean showExceptions = true
20+
boolean showCauses = true
21+
boolean showStackTraces = true
22+
boolean showFullStackTraces = false
1923
long slowThreshold = 2000
2024
boolean showSummary = true
2125
boolean showStandardStreams = false
@@ -25,6 +29,7 @@ class TestLoggerExtension {
2529
boolean showPassed = true
2630
boolean showSkipped = true
2731
boolean showFailed = true
32+
boolean showSimpleNames = false
2833

2934
private final ConsoleOutput consoleType
3035
private Set<String> configuredProperties = []
@@ -37,6 +42,9 @@ class TestLoggerExtension {
3742
private TestLoggerExtension(TestLoggerExtension source) {
3843
this.theme = source.theme
3944
this.showExceptions = source.showExceptions
45+
this.showCauses = source.showCauses
46+
this.showStackTraces = source.showStackTraces
47+
this.showFullStackTraces = source.showFullStackTraces
4048
this.slowThreshold = source.slowThreshold
4149
this.showSummary = source.showSummary
4250
this.showStandardStreams = source.showStandardStreams
@@ -46,6 +54,7 @@ class TestLoggerExtension {
4654
this.showPassed = source.showPassed
4755
this.showSkipped = source.showSkipped
4856
this.showFailed = source.showFailed
57+
this.showSimpleNames = source.showSimpleNames
4958
this.consoleType = source.consoleType
5059
this.configuredProperties = source.configuredProperties
5160
}
@@ -73,6 +82,21 @@ class TestLoggerExtension {
7382
this.configuredProperties << 'showExceptions'
7483
}
7584

85+
void setShowCauses(boolean showCauses) {
86+
this.showCauses = showCauses
87+
this.configuredProperties << 'showCauses'
88+
}
89+
90+
void setShowStackTraces(boolean showStackTraces) {
91+
this.showStackTraces = showStackTraces
92+
this.configuredProperties << 'showStackTraces'
93+
}
94+
95+
void setShowFullStackTraces(boolean showFullStackTraces) {
96+
this.showFullStackTraces = showFullStackTraces
97+
this.configuredProperties << 'showFullStackTraces'
98+
}
99+
76100
void setSlowThreshold(long slowThreshold) {
77101
this.slowThreshold = slowThreshold
78102
this.configuredProperties << 'slowThreshold'
@@ -118,6 +142,11 @@ class TestLoggerExtension {
118142
this.configuredProperties << 'showFailed'
119143
}
120144

145+
void setShowSimpleNames(boolean showSimpleNames) {
146+
this.showSimpleNames = showSimpleNames
147+
this.configuredProperties << 'showSimpleNames'
148+
}
149+
121150
TestLoggerExtension undecorate() {
122151
new TestLoggerExtension(this)
123152
}
@@ -127,6 +156,22 @@ class TestLoggerExtension {
127156
this.showStandardStreams = testLogging.showStandardStreams
128157
this.configuredProperties -= 'showStandardStreams'
129158
}
159+
if (!this.configuredProperties.contains('showExceptions')) {
160+
this.showExceptions = testLogging.showExceptions
161+
this.configuredProperties -= 'showExceptions'
162+
}
163+
if (!this.configuredProperties.contains('showCauses')) {
164+
this.showCauses = testLogging.showCauses
165+
this.configuredProperties -= 'showCauses'
166+
}
167+
if (!this.configuredProperties.contains('showStackTraces')) {
168+
this.showStackTraces = testLogging.showStackTraces
169+
this.configuredProperties -= 'showStackTraces'
170+
}
171+
if (!this.configuredProperties.contains('showFullStackTraces')) {
172+
this.showFullStackTraces = testLogging.showStackTraces && testLogging.exceptionFormat == FULL
173+
this.configuredProperties -= 'showFullStackTraces'
174+
}
130175

131176
this
132177
}
@@ -146,6 +191,9 @@ class TestLoggerExtension {
146191
TestLoggerExtension applyOverrides(Map<String, String> overrides) {
147192
override(overrides, 'theme', ThemeType)
148193
override(overrides, 'showExceptions', Boolean)
194+
override(overrides, 'showCauses', Boolean)
195+
override(overrides, 'showStackTraces', Boolean)
196+
override(overrides, 'showFullStackTraces', Boolean)
149197
override(overrides, 'slowThreshold', Long)
150198
override(overrides, 'showSummary', Boolean)
151199
override(overrides, 'showStandardStreams', Boolean)
@@ -155,6 +203,7 @@ class TestLoggerExtension {
155203
override(overrides, 'showPassed', Boolean)
156204
override(overrides, 'showSkipped', Boolean)
157205
override(overrides, 'showFailed', Boolean)
206+
override(overrides, 'showSimpleNames', Boolean)
158207

159208
this
160209
}

src/main/groovy/com/adarshr/gradle/testlogger/TestResultWrapper.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import com.adarshr.gradle.testlogger.util.TimeUtils
44
import groovy.transform.CompileStatic
55
import org.gradle.api.tasks.testing.TestResult
66

7+
import static org.gradle.api.tasks.testing.TestResult.ResultType.SKIPPED
8+
79
@CompileStatic
810
class TestResultWrapper {
911

@@ -18,7 +20,7 @@ class TestResultWrapper {
1820

1921
boolean isLoggable() {
2022
testLoggerExtension.showPassed && testResult.successfulTestCount ||
21-
testLoggerExtension.showSkipped && testResult.skippedTestCount ||
23+
testLoggerExtension.showSkipped && (testResult.resultType == SKIPPED || testResult.skippedTestCount) ||
2224
testLoggerExtension.showFailed && testResult.failedTestCount
2325
}
2426

0 commit comments

Comments
 (0)