Skip to content

Commit f0658f7

Browse files
committed
Merge branch 'release/3.2.0'
2 parents a6aca88 + 09dc262 commit f0658f7

File tree

9 files changed

+110
-12
lines changed

9 files changed

+110
-12
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## [v3.2.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v3.2.0) (2022-02-27)
4+
5+
[Full Changelog](https://github.com/radarsh/gradle-test-logger-plugin/compare/v3.1.0...v3.2.0)
6+
7+
**Implemented enhancements:**
8+
9+
- Add filter: hide regular passing tests, show slow passing tests [\#158](https://github.com/radarsh/gradle-test-logger-plugin/issues/158)
10+
11+
**Merged pull requests:**
12+
13+
- Bump byte-buddy from 1.12.6 to 1.12.7 [\#255](https://github.com/radarsh/gradle-test-logger-plugin/pull/255) ([dependabot[bot]](https://github.com/apps/dependabot))
14+
- Bump com.gradle.enterprise from 3.8 to 3.8.1 [\#254](https://github.com/radarsh/gradle-test-logger-plugin/pull/254) ([dependabot[bot]](https://github.com/apps/dependabot))
15+
- Bump com.gradle.plugin-publish from 0.18.0 to 0.19.0 [\#251](https://github.com/radarsh/gradle-test-logger-plugin/pull/251) ([dependabot[bot]](https://github.com/apps/dependabot))
16+
- Bump com.gradle.enterprise from 3.7.2 to 3.8 [\#250](https://github.com/radarsh/gradle-test-logger-plugin/pull/250) ([dependabot[bot]](https://github.com/apps/dependabot))
17+
- Bump byte-buddy from 1.12.2 to 1.12.6 [\#249](https://github.com/radarsh/gradle-test-logger-plugin/pull/249) ([dependabot[bot]](https://github.com/apps/dependabot))
18+
- Bump com.gradle.enterprise from 3.4.1 to 3.7.2 [\#244](https://github.com/radarsh/gradle-test-logger-plugin/pull/244) ([dependabot[bot]](https://github.com/apps/dependabot))
19+
- Bump byte-buddy from 1.11.22 to 1.12.2 [\#243](https://github.com/radarsh/gradle-test-logger-plugin/pull/243) ([dependabot[bot]](https://github.com/apps/dependabot))
20+
- Bump com.gradle.plugin-publish from 0.17.0 to 0.18.0 [\#242](https://github.com/radarsh/gradle-test-logger-plugin/pull/242) ([dependabot[bot]](https://github.com/apps/dependabot))
21+
- Bump com.gradle.plugin-publish from 0.16.0 to 0.17.0 [\#238](https://github.com/radarsh/gradle-test-logger-plugin/pull/238) ([dependabot[bot]](https://github.com/apps/dependabot))
22+
- adds filter for showing only slow tests [\#207](https://github.com/radarsh/gradle-test-logger-plugin/pull/207) ([grimmjo](https://github.com/grimmjo))
23+
324
## [v3.1.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v3.1.0) (2021-11-02)
425

526
[Full Changelog](https://github.com/radarsh/gradle-test-logger-plugin/compare/v3.0.0...v3.1.0)

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Scroll down for more themes and customisation options or visit the [screenshots
2727

2828
```groovy
2929
plugins {
30-
id 'com.adarshr.test-logger' version '3.1.0'
30+
id 'com.adarshr.test-logger' version '3.2.0'
3131
}
3232
```
3333

@@ -41,7 +41,7 @@ buildscript {
4141
}
4242
}
4343
dependencies {
44-
classpath 'com.adarshr:gradle-test-logger-plugin:3.1.0'
44+
classpath 'com.adarshr:gradle-test-logger-plugin:3.2.0'
4545
}
4646
}
4747
@@ -76,6 +76,7 @@ testlogger {
7676
showPassed true
7777
showSkipped true
7878
showFailed true
79+
showOnlySlow false
7980
showStandardStreams false
8081
showPassedStandardStreams true
8182
showSkippedStandardStreams true
@@ -266,10 +267,11 @@ testlogger {
266267
showPassed false
267268
showSkipped false
268269
showFailed true
270+
showOnlySlow false
269271
}
270272
```
271273

272-
By default all the above three flags are turned on. If you have chosen to display standard streams by setting
274+
By default the flags `showPassed`, `showSkipped` and `showFailed` are turned on while `showOnlySlow` will be off. If you have chosen to display standard streams by setting
273275
`showStandardStreams` flag to `true`, any output produced by filtered out tests will not be displayed.
274276

275277
### Change log level
@@ -329,6 +331,7 @@ testlogger {
329331
showPassed = true
330332
showSkipped = true
331333
showFailed = true
334+
showOnlySlow = false
332335
showStandardStreams = false
333336
showPassedStandardStreams = true
334337
showSkippedStandardStreams = true

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
id 'maven-publish'
1212
id 'idea'
1313
id 'jacoco'
14-
id 'com.gradle.plugin-publish' version '0.16.0'
14+
id 'com.gradle.plugin-publish' version '0.19.0'
1515
id 'com.github.kt3k.coveralls' version '2.12.0'
1616
}
1717

@@ -44,7 +44,7 @@ dependencies {
4444

4545
testImplementation gradleTestKit()
4646
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
47-
testImplementation 'net.bytebuddy:byte-buddy:1.11.22'
47+
testImplementation 'net.bytebuddy:byte-buddy:1.12.7'
4848
testImplementation 'org.objenesis:objenesis:3.2'
4949
testImplementation 'commons-io:commons-io:2.11.0'
5050

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=3.1.0
1+
version=3.2.0
22
group=com.adarshr
33
org.gradle.daemon=true
44
org.gradle.caching=false

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'com.gradle.enterprise' version '3.4.1'
2+
id 'com.gradle.enterprise' version '3.8.1'
33
}
44

55
gradleEnterprise {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
3737
private final Property<Boolean> showSkipped
3838
private final Property<Boolean> showFailed
3939
private final Property<Boolean> showSimpleNames
40+
private final Property<Boolean> showOnlySlow
4041

4142
private final SetProperty<TestLogEvent> originalTestLoggingEvents
4243
private final TestLoggerExtension projectExtension
@@ -60,6 +61,7 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
6061
this.showSkipped = project.objects.property(Boolean)
6162
this.showFailed = project.objects.property(Boolean)
6263
this.showSimpleNames = project.objects.property(Boolean)
64+
this.showOnlySlow = project.objects.property(Boolean)
6365

6466
this.originalTestLoggingEvents = project.objects.setProperty(TestLogEvent)
6567
this.projectExtension = project.extensions.findByType(TestLoggerExtension)
@@ -227,6 +229,15 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
227229
.getOrElse(false)
228230
}
229231

232+
Boolean getShowOnlySlow() {
233+
providers.systemProperty('testlogger.showOnlySlow')
234+
.forUseAtConfigurationTime()
235+
.map { Boolean.valueOf(it) }
236+
.orElse(showOnlySlow)
237+
.orElse(projectExtension.@showOnlySlow)
238+
.getOrElse(false)
239+
}
240+
230241
@PackageScope
231242
void setOriginalTestLoggingEvents(Set<TestLogEvent> events) {
232243
this.originalTestLoggingEvents.value(events).finalizeValue()
@@ -328,4 +339,9 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
328339
void setShowSimpleNames(Boolean showSimpleNames) {
329340
this.showSimpleNames.set(showSimpleNames)
330341
}
342+
343+
@Override
344+
void setShowOnlySlow(Boolean showOnlySlow) {
345+
this.showOnlySlow.set(showOnlySlow)
346+
}
331347
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,9 @@ abstract class TestLoggerExtensionProperties {
8484
* Whether simple class names should be used for displaying test suites. Defaults to false.
8585
*/
8686
Boolean showSimpleNames
87+
88+
/**
89+
* Whether only slow tests should be shown. Defaults to false.
90+
*/
91+
Boolean showOnlySlow
8792
}

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ 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-
97
@CompileStatic
108
class TestResultWrapper {
119

@@ -19,9 +17,17 @@ class TestResultWrapper {
1917
}
2018

2119
boolean isLoggable() {
22-
testLoggerExtension.showPassed && testResult.successfulTestCount ||
23-
testLoggerExtension.showSkipped && (testResult.resultType == SKIPPED || testResult.skippedTestCount) ||
24-
testLoggerExtension.showFailed && testResult.failedTestCount
20+
boolean showPassed = testLoggerExtension.showPassed && testResult.successfulTestCount
21+
boolean showSkipped = testLoggerExtension.showSkipped && (testResult.resultType == TestResult.ResultType.SKIPPED || testResult.skippedTestCount)
22+
boolean showFailed = testLoggerExtension.showFailed && testResult.failedTestCount
23+
if (showPassed || showSkipped || showFailed) {
24+
boolean showSlow = testLoggerExtension.showOnlySlow && (!isTooSlow() || !isMediumSlow())
25+
if (showSlow) {
26+
return false
27+
}
28+
return true
29+
}
30+
return false
2531
}
2632

2733
boolean isStandardStreamLoggable() {

src/test/groovy/com/adarshr/gradle/testlogger/TestResultWrapperSpec.groovy

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,32 @@ class TestResultWrapperSpec extends Specification {
127127
10001 | false
128128
}
129129

130+
@Unroll
131+
def "loggable returns false if showOnlySlow is turned #showOnlySlow"() {
132+
given:
133+
testResultMock.endTime >> 20000
134+
testResultMock.startTime >> 10000
135+
testResultMock.successfulTestCount >> 1
136+
testResultMock.failedTestCount >> 1
137+
testResultMock.skippedTestCount >> 1
138+
testLoggerExtensionMock.slowThreshold >> slowThreshold
139+
testLoggerExtensionMock.showOnlySlow >> showOnlySlow
140+
testLoggerExtensionMock.showFailed >> showFailed
141+
testLoggerExtensionMock.showPassed >> showPassed
142+
expect:
143+
wrapper.isLoggable() == result
144+
where:
145+
slowThreshold | showOnlySlow | showPassed | showFailed | result
146+
10000 | true | true | true | true
147+
9999 | false | true | true | true
148+
10000 | true | true | false | true
149+
9999 | false | true | false | true
150+
10000 | true | false | true | true
151+
9999 | false | false | true | true
152+
10000 | true | false | false | false
153+
9999 | false | false | false | false
154+
}
155+
130156
@Unroll
131157
def "is medium slow returns #result if slow threshold is #slowThreshold"() {
132158
given:
@@ -149,4 +175,25 @@ class TestResultWrapperSpec extends Specification {
149175
expect:
150176
wrapper.duration == '10s'
151177
}
178+
179+
@Unroll
180+
def "loggable returns true if test is too slow but the type is disabled"() {
181+
given:
182+
testLoggerExtensionMock.showPassed >> showPassed
183+
testLoggerExtensionMock.showSkipped >> showSkipped
184+
testLoggerExtensionMock.showFailed >> showFailed
185+
testLoggerExtensionMock.showOnlySlow >> true
186+
testResultMock.successfulTestCount >> successfulCount
187+
testResultMock.skippedTestCount >> skippedCount
188+
testResultMock.failedTestCount >> failedCount
189+
testResultMock.endTime >> 20000
190+
testResultMock.startTime >> 10000
191+
expect:
192+
!wrapper.loggable
193+
where:
194+
successfulCount | skippedCount | failedCount | showPassed | showSkipped | showFailed
195+
1 | 0 | 0 | false | true | true
196+
0 | 1 | 0 | true | false | true
197+
0 | 0 | 1 | true | true | false
198+
}
152199
}

0 commit comments

Comments
 (0)