Skip to content

Commit

Permalink
Merge branch 'release/1.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
radarsh committed May 29, 2019
2 parents 450dc74 + 9bb9b50 commit 6bb92a9
Show file tree
Hide file tree
Showing 37 changed files with 809 additions and 112 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
key: v1-dependencies-{{ checksum "build.gradle" }}
- run:
name: Run tests
command: GRADLE_OPTS="-Xms256m -Xmx2048m" ./gradlew build --no-daemon
command: GRADLE_OPTS="-Xms256m -Xmx2048m" ./gradlew build --no-daemon --scan
- run:
name: Code coverage
command: GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew jacocoTestReport coveralls --no-daemon
command: GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew jacocoTestReport coveralls --no-daemon --scan
- run:
name: Save reports
command: |
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
- run:
name: Publish plugin
command:
GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew clean publishPlugins --no-daemon
GRADLE_OPTS="-Xms256m -Xmx1024m" ./gradlew clean publishPlugins --no-daemon --scan
-Pgradle.publish.key=${GRADLE_PUBLISH_KEY}
-Pgradle.publish.secret=${GRADLE_PUBLISH_SECRET}

Expand Down
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
# Change Log

## [v1.6.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v1.6.0) (2018-11-20)
## [v1.7.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v1.7.0) (2019-05-29)
[Full Changelog](https://github.com/radarsh/gradle-test-logger-plugin/compare/v1.6.0...v1.7.0)

**Closed issues:**

- Not enough details about exception thrown by the test. [\#118](https://github.com/radarsh/gradle-test-logger-plugin/issues/118)
- NoSuchMethodError: org.fusesource.jansi.Ansi.fgGreen\(\)Lorg/fusesource/jansi/Ans [\#116](https://github.com/radarsh/gradle-test-logger-plugin/issues/116)
- Mocha on dark terminals [\#115](https://github.com/radarsh/gradle-test-logger-plugin/issues/115)
- Add support for @Nested and @DisplayName [\#106](https://github.com/radarsh/gradle-test-logger-plugin/issues/106)
- Get rid of logs original test logs [\#105](https://github.com/radarsh/gradle-test-logger-plugin/issues/105)
- Prints corrupted json [\#104](https://github.com/radarsh/gradle-test-logger-plugin/issues/104)
- Bad encoding on standard and mocha themes when printing to Eclipse's console [\#92](https://github.com/radarsh/gradle-test-logger-plugin/issues/92)
- Testsuite fatal error output not shown [\#89](https://github.com/radarsh/gradle-test-logger-plugin/issues/89)

**Merged pull requests:**

- Show full stacktraces [\#119](https://github.com/radarsh/gradle-test-logger-plugin/pull/119) ([radarsh](https://github.com/radarsh))
- Improve Windows build stability [\#117](https://github.com/radarsh/gradle-test-logger-plugin/pull/117) ([radarsh](https://github.com/radarsh))
- 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))
- Configure build-scan plugin [\#112](https://github.com/radarsh/gradle-test-logger-plugin/pull/112) ([aalmiray](https://github.com/aalmiray))
- Use classDisplayName for friendlier suite names [\#109](https://github.com/radarsh/gradle-test-logger-plugin/pull/109) ([radarsh](https://github.com/radarsh))
- Fix double escaping of brackets [\#108](https://github.com/radarsh/gradle-test-logger-plugin/pull/108) ([radarsh](https://github.com/radarsh))

## [v1.6.0](https://github.com/radarsh/gradle-test-logger-plugin/tree/v1.6.0) (2018-11-20)
[Full Changelog](https://github.com/radarsh/gradle-test-logger-plugin/compare/v1.5.0...v1.6.0)

**Implemented enhancements:**
Expand Down
57 changes: 46 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Scroll down for more themes and customisation options or visit the [screenshots

```groovy
plugins {
id 'com.adarshr.test-logger' version '1.6.0'
id 'com.adarshr.test-logger' version '1.7.0'
}
```

Expand All @@ -39,7 +39,7 @@ buildscript {
}
}
dependencies {
classpath 'com.adarshr:gradle-test-logger-plugin:1.6.0'
classpath 'com.adarshr:gradle-test-logger-plugin:1.7.0'
}
}
Expand All @@ -57,8 +57,12 @@ The following shows the complete default configuration applied when you configur
testlogger {
theme 'standard'
showExceptions true
showStackTraces true
showFullStackTraces false
showCauses true
slowThreshold 2000
showSummary true
showSimpleNames false
showPassed true
showSkipped true
showFailed true
Expand Down Expand Up @@ -164,6 +168,17 @@ testlogger {
}
```

### Show simple names

If you don't like seeing long, fully-qualified class names being used for displaying the test suite names, you can choose to
show only [simple names](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getSimpleName--) by setting the below flag to true.

```groovy
testlogger {
showSimpleNames true
}
```

### Show standard streams

The display of standard output and error streams alongside the test logs can be controlled using the below configuration.
Expand Down Expand Up @@ -212,6 +227,35 @@ testlogger {
By default all the above three flags are turned on. 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.

### Relationship between `testlogger` and `Test.testLogging`

Where possible, the plugin's `testlogger` extension tries to react to equivalent properties of Gradle's `Test.testLogging`
extension. However, if a value is explicitly configured under the `testlogger` extension, the plugin __does not__ react to the
corresponding property of `Test.testLogging`. The below table demonstrates this in more detail.

| Property | `Test.testLogging` value | `testlogging` value | Effective value |
|---------------------------|---------------------------------------|------------------------|---------------- |
| `showStandardStreams` | `true` | not configured | `true` |
| `showStandardStreams` | `true` | `false` | `false` |
| `showStandardStreams` | `false` | `true` | `true` |
| `showExceptions` | `true` | not configured | `true` |
| `showExceptions` | `true` | `false` | `false` |
| `showExceptions` | `false` | `true` | `true` |
| `showStackTraces` | `true` | not configured | `true` |
| `showStackTraces` | `true` | `false` | `false` |
| `showStackTraces` | `false` | `true` | `true` |
| `showFullStackTraces` | `testLogging.exceptionFormat = FULL` | not configured | `true` |
| `showFullStackTraces` | `testLogging.exceptionFormat = SHORT` | not configured | `false` |
| `showFullStackTraces` | `testLogging.exceptionFormat = FULL` | `false` | `false` |
| `showFullStackTraces` | `testLogging.exceptionFormat = SHORT` | `true` | `true` |
| `showCauses` | `true` | not configured | `true` |
| `showCauses` | `true` | `false` | `false` |
| `showCauses` | `false` | `true` | `true` |

In other words, an explicitly configured `testlogger` property, despite it being `false`, takes precedence over any
value of `Test.testLogging`.


## FAQ

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

### How are `testlogger` and `Test.testLogging` related?

Until recently, they were unrelated. While this plugin's `testlogger` has many properties named identical to the ones in Gradle's
`Test.testLogging`, to a large extent, they are kept isolated by design.

However, as of this writing `testlogger.showStandardStreams` property has been made to react to `testLogging.showStandardStreams`
property as long as one doesn't configure a value for `testlogger.showStandardStreams`. If a value is configured for
`testlogger.showStandardStreams` (even if it is `false`), the plugin ignores `testLogging.showStandardStreams` altogether.

### Can this plugin co-exist with junit-platform-gradle-plugin?

Due to certain unknown reasons, `junit-platform-gradle-plugin` is incompatible with `gradle-test-logger-plugin`. If you are still
Expand Down
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ buildscript {
}

plugins {
id 'com.gradle.build-scan' version '1.16'
id 'groovy'
id 'java-gradle-plugin'
id 'maven-publish'
Expand All @@ -14,6 +15,11 @@ plugins {
id 'com.github.kt3k.coveralls' version '2.8.2'
}

buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}

def thisPlugin =
new GroovyScriptEngine(file('src/main/groovy').absolutePath, this.class.classLoader)
.loadScriptByName('com/adarshr/gradle/testlogger/TestLoggerPlugin.groovy')
Expand Down Expand Up @@ -76,6 +82,10 @@ test {
testClassesDirs += sourceSets.functionalTest.output.classesDirs
classpath += sourceSets.functionalTest.runtimeClasspath
systemProperty 'file.encoding', 'UTF-8'

// testLogging {
// exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
// }

testlogger {
theme 'mocha'
Expand Down
6 changes: 5 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
version=1.6.0
version=1.7.0
group=com.adarshr

org.gradle.daemon = true
org.gradle.caching = true
org.gradle.parallel = true
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,23 @@ class TestDescriptorWrapper {
escape(testDescriptor.className)
}

@CompileDynamic
String getClassDisplayName() {
def className = testDescriptor.className
def classDisplayName = testDescriptor.properties.classDisplayName as String
def useClassDisplayName = classDisplayName && classDisplayName != className && !className.endsWith(classDisplayName)

if (testLoggerExtension.showSimpleNames) {
className = className.substring(className.lastIndexOf('.') + 1)
className = className.substring(className.lastIndexOf('$') + 1)
}

escape(useClassDisplayName ? classDisplayName : className)
}

@CompileDynamic
String getDisplayName() {
escape(testDescriptor.properties.displayName ?: name)
escape(testDescriptor.properties.displayName ?: testDescriptor.name as String)
}

String getSuiteKey() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import org.gradle.api.tasks.testing.logging.TestLogging
import static com.adarshr.gradle.testlogger.theme.ThemeType.PLAIN
import static com.adarshr.gradle.testlogger.theme.ThemeType.STANDARD
import static org.gradle.api.logging.configuration.ConsoleOutput.Plain
import static org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL

@CompileStatic
@SuppressWarnings("GroovyUnusedDeclaration")
class TestLoggerExtension {

ThemeType theme = STANDARD
boolean showExceptions = true
boolean showCauses = true
boolean showStackTraces = true
boolean showFullStackTraces = false
long slowThreshold = 2000
boolean showSummary = true
boolean showStandardStreams = false
Expand All @@ -25,6 +29,7 @@ class TestLoggerExtension {
boolean showPassed = true
boolean showSkipped = true
boolean showFailed = true
boolean showSimpleNames = false

private final ConsoleOutput consoleType
private Set<String> configuredProperties = []
Expand All @@ -37,6 +42,9 @@ class TestLoggerExtension {
private TestLoggerExtension(TestLoggerExtension source) {
this.theme = source.theme
this.showExceptions = source.showExceptions
this.showCauses = source.showCauses
this.showStackTraces = source.showStackTraces
this.showFullStackTraces = source.showFullStackTraces
this.slowThreshold = source.slowThreshold
this.showSummary = source.showSummary
this.showStandardStreams = source.showStandardStreams
Expand All @@ -46,6 +54,7 @@ class TestLoggerExtension {
this.showPassed = source.showPassed
this.showSkipped = source.showSkipped
this.showFailed = source.showFailed
this.showSimpleNames = source.showSimpleNames
this.consoleType = source.consoleType
this.configuredProperties = source.configuredProperties
}
Expand Down Expand Up @@ -73,6 +82,21 @@ class TestLoggerExtension {
this.configuredProperties << 'showExceptions'
}

void setShowCauses(boolean showCauses) {
this.showCauses = showCauses
this.configuredProperties << 'showCauses'
}

void setShowStackTraces(boolean showStackTraces) {
this.showStackTraces = showStackTraces
this.configuredProperties << 'showStackTraces'
}

void setShowFullStackTraces(boolean showFullStackTraces) {
this.showFullStackTraces = showFullStackTraces
this.configuredProperties << 'showFullStackTraces'
}

void setSlowThreshold(long slowThreshold) {
this.slowThreshold = slowThreshold
this.configuredProperties << 'slowThreshold'
Expand Down Expand Up @@ -118,6 +142,11 @@ class TestLoggerExtension {
this.configuredProperties << 'showFailed'
}

void setShowSimpleNames(boolean showSimpleNames) {
this.showSimpleNames = showSimpleNames
this.configuredProperties << 'showSimpleNames'
}

TestLoggerExtension undecorate() {
new TestLoggerExtension(this)
}
Expand All @@ -127,6 +156,22 @@ class TestLoggerExtension {
this.showStandardStreams = testLogging.showStandardStreams
this.configuredProperties -= 'showStandardStreams'
}
if (!this.configuredProperties.contains('showExceptions')) {
this.showExceptions = testLogging.showExceptions
this.configuredProperties -= 'showExceptions'
}
if (!this.configuredProperties.contains('showCauses')) {
this.showCauses = testLogging.showCauses
this.configuredProperties -= 'showCauses'
}
if (!this.configuredProperties.contains('showStackTraces')) {
this.showStackTraces = testLogging.showStackTraces
this.configuredProperties -= 'showStackTraces'
}
if (!this.configuredProperties.contains('showFullStackTraces')) {
this.showFullStackTraces = testLogging.showStackTraces && testLogging.exceptionFormat == FULL
this.configuredProperties -= 'showFullStackTraces'
}

this
}
Expand All @@ -146,6 +191,9 @@ class TestLoggerExtension {
TestLoggerExtension applyOverrides(Map<String, String> overrides) {
override(overrides, 'theme', ThemeType)
override(overrides, 'showExceptions', Boolean)
override(overrides, 'showCauses', Boolean)
override(overrides, 'showStackTraces', Boolean)
override(overrides, 'showFullStackTraces', Boolean)
override(overrides, 'slowThreshold', Long)
override(overrides, 'showSummary', Boolean)
override(overrides, 'showStandardStreams', Boolean)
Expand All @@ -155,6 +203,7 @@ class TestLoggerExtension {
override(overrides, 'showPassed', Boolean)
override(overrides, 'showSkipped', Boolean)
override(overrides, 'showFailed', Boolean)
override(overrides, 'showSimpleNames', Boolean)

this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ 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 @@ -18,7 +20,7 @@ class TestResultWrapper {

boolean isLoggable() {
testLoggerExtension.showPassed && testResult.successfulTestCount ||
testLoggerExtension.showSkipped && testResult.skippedTestCount ||
testLoggerExtension.showSkipped && (testResult.resultType == SKIPPED || testResult.skippedTestCount) ||
testLoggerExtension.showFailed && testResult.failedTestCount
}

Expand Down
Loading

0 comments on commit 6bb92a9

Please sign in to comment.