Skip to content

Commit

Permalink
Merge branch 'release/3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
radarsh committed Feb 27, 2022
2 parents a6aca88 + 09dc262 commit f0658f7
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 12 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## [v3.2.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v3.2.0) (2022-02-27)

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

**Implemented enhancements:**

- Add filter: hide regular passing tests, show slow passing tests [\#158](https://github.com/radarsh/gradle-test-logger-plugin/issues/158)

**Merged pull requests:**

- 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))
- 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))
- 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))
- 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))
- 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))
- 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))
- 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))
- 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))
- 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))
- adds filter for showing only slow tests [\#207](https://github.com/radarsh/gradle-test-logger-plugin/pull/207) ([grimmjo](https://github.com/grimmjo))

## [v3.1.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v3.1.0) (2021-11-02)

[Full Changelog](https://github.com/radarsh/gradle-test-logger-plugin/compare/v3.0.0...v3.1.0)
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Scroll down for more themes and customisation options or visit the [screenshots

```groovy
plugins {
id 'com.adarshr.test-logger' version '3.1.0'
id 'com.adarshr.test-logger' version '3.2.0'
}
```

Expand All @@ -41,7 +41,7 @@ buildscript {
}
}
dependencies {
classpath 'com.adarshr:gradle-test-logger-plugin:3.1.0'
classpath 'com.adarshr:gradle-test-logger-plugin:3.2.0'
}
}
Expand Down Expand Up @@ -76,6 +76,7 @@ testlogger {
showPassed true
showSkipped true
showFailed true
showOnlySlow false
showStandardStreams false
showPassedStandardStreams true
showSkippedStandardStreams true
Expand Down Expand Up @@ -266,10 +267,11 @@ testlogger {
showPassed false
showSkipped false
showFailed true
showOnlySlow false
}
```

By default all the above three flags are turned on. If you have chosen to display standard streams by setting
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
`showStandardStreams` flag to `true`, any output produced by filtered out tests will not be displayed.

### Change log level
Expand Down Expand Up @@ -329,6 +331,7 @@ testlogger {
showPassed = true
showSkipped = true
showFailed = true
showOnlySlow = false
showStandardStreams = false
showPassedStandardStreams = true
showSkippedStandardStreams = true
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id 'maven-publish'
id 'idea'
id 'jacoco'
id 'com.gradle.plugin-publish' version '0.16.0'
id 'com.gradle.plugin-publish' version '0.19.0'
id 'com.github.kt3k.coveralls' version '2.12.0'
}

Expand Down Expand Up @@ -44,7 +44,7 @@ dependencies {

testImplementation gradleTestKit()
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
testImplementation 'net.bytebuddy:byte-buddy:1.11.22'
testImplementation 'net.bytebuddy:byte-buddy:1.12.7'
testImplementation 'org.objenesis:objenesis:3.2'
testImplementation 'commons-io:commons-io:2.11.0'

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=3.1.0
version=3.2.0
group=com.adarshr
org.gradle.daemon=true
org.gradle.caching=false
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.gradle.enterprise' version '3.4.1'
id 'com.gradle.enterprise' version '3.8.1'
}

gradleEnterprise {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
private final Property<Boolean> showSkipped
private final Property<Boolean> showFailed
private final Property<Boolean> showSimpleNames
private final Property<Boolean> showOnlySlow

private final SetProperty<TestLogEvent> originalTestLoggingEvents
private final TestLoggerExtension projectExtension
Expand All @@ -60,6 +61,7 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
this.showSkipped = project.objects.property(Boolean)
this.showFailed = project.objects.property(Boolean)
this.showSimpleNames = project.objects.property(Boolean)
this.showOnlySlow = project.objects.property(Boolean)

this.originalTestLoggingEvents = project.objects.setProperty(TestLogEvent)
this.projectExtension = project.extensions.findByType(TestLoggerExtension)
Expand Down Expand Up @@ -227,6 +229,15 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
.getOrElse(false)
}

Boolean getShowOnlySlow() {
providers.systemProperty('testlogger.showOnlySlow')
.forUseAtConfigurationTime()
.map { Boolean.valueOf(it) }
.orElse(showOnlySlow)
.orElse(projectExtension.@showOnlySlow)
.getOrElse(false)
}

@PackageScope
void setOriginalTestLoggingEvents(Set<TestLogEvent> events) {
this.originalTestLoggingEvents.value(events).finalizeValue()
Expand Down Expand Up @@ -328,4 +339,9 @@ class TestLoggerExtension extends TestLoggerExtensionProperties {
void setShowSimpleNames(Boolean showSimpleNames) {
this.showSimpleNames.set(showSimpleNames)
}

@Override
void setShowOnlySlow(Boolean showOnlySlow) {
this.showOnlySlow.set(showOnlySlow)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ abstract class TestLoggerExtensionProperties {
* Whether simple class names should be used for displaying test suites. Defaults to false.
*/
Boolean showSimpleNames

/**
* Whether only slow tests should be shown. Defaults to false.
*/
Boolean showOnlySlow
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import com.adarshr.gradle.testlogger.util.TimeUtils
import groovy.transform.CompileStatic
import org.gradle.api.tasks.testing.TestResult

import static org.gradle.api.tasks.testing.TestResult.ResultType.SKIPPED

@CompileStatic
class TestResultWrapper {

Expand All @@ -19,9 +17,17 @@ class TestResultWrapper {
}

boolean isLoggable() {
testLoggerExtension.showPassed && testResult.successfulTestCount ||
testLoggerExtension.showSkipped && (testResult.resultType == SKIPPED || testResult.skippedTestCount) ||
testLoggerExtension.showFailed && testResult.failedTestCount
boolean showPassed = testLoggerExtension.showPassed && testResult.successfulTestCount
boolean showSkipped = testLoggerExtension.showSkipped && (testResult.resultType == TestResult.ResultType.SKIPPED || testResult.skippedTestCount)
boolean showFailed = testLoggerExtension.showFailed && testResult.failedTestCount
if (showPassed || showSkipped || showFailed) {
boolean showSlow = testLoggerExtension.showOnlySlow && (!isTooSlow() || !isMediumSlow())
if (showSlow) {
return false
}
return true
}
return false
}

boolean isStandardStreamLoggable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,32 @@ class TestResultWrapperSpec extends Specification {
10001 | false
}

@Unroll
def "loggable returns false if showOnlySlow is turned #showOnlySlow"() {
given:
testResultMock.endTime >> 20000
testResultMock.startTime >> 10000
testResultMock.successfulTestCount >> 1
testResultMock.failedTestCount >> 1
testResultMock.skippedTestCount >> 1
testLoggerExtensionMock.slowThreshold >> slowThreshold
testLoggerExtensionMock.showOnlySlow >> showOnlySlow
testLoggerExtensionMock.showFailed >> showFailed
testLoggerExtensionMock.showPassed >> showPassed
expect:
wrapper.isLoggable() == result
where:
slowThreshold | showOnlySlow | showPassed | showFailed | result
10000 | true | true | true | true
9999 | false | true | true | true
10000 | true | true | false | true
9999 | false | true | false | true
10000 | true | false | true | true
9999 | false | false | true | true
10000 | true | false | false | false
9999 | false | false | false | false
}

@Unroll
def "is medium slow returns #result if slow threshold is #slowThreshold"() {
given:
Expand All @@ -149,4 +175,25 @@ class TestResultWrapperSpec extends Specification {
expect:
wrapper.duration == '10s'
}

@Unroll
def "loggable returns true if test is too slow but the type is disabled"() {
given:
testLoggerExtensionMock.showPassed >> showPassed
testLoggerExtensionMock.showSkipped >> showSkipped
testLoggerExtensionMock.showFailed >> showFailed
testLoggerExtensionMock.showOnlySlow >> true
testResultMock.successfulTestCount >> successfulCount
testResultMock.skippedTestCount >> skippedCount
testResultMock.failedTestCount >> failedCount
testResultMock.endTime >> 20000
testResultMock.startTime >> 10000
expect:
!wrapper.loggable
where:
successfulCount | skippedCount | failedCount | showPassed | showSkipped | showFailed
1 | 0 | 0 | false | true | true
0 | 1 | 0 | true | false | true
0 | 0 | 1 | true | true | false
}
}

0 comments on commit f0658f7

Please sign in to comment.