radarsh / gradle-test-logger-plugin Goto Github PK
View Code? Open in Web Editor NEWA Gradle plugin for printing beautiful logs on the console while running tests
License: Apache License 2.0
A Gradle plugin for printing beautiful logs on the console while running tests
License: Apache License 2.0
Fix CircleCI build instability
Fix the broken coverage badge
Add AppVeyor build badge to README
Upgrade to Gradle 4.10
Hi,
i really like your plugin and the well formatted output but the bright yellow of the test class name is really hard to read on bright backgrounds like jenkins has.
Would it be possible to exchange all bright yellows to another color?
Thanks
Currently if maxParallelForks
is set to anything other than 1
, the plugin throws an exception. This can be quite limiting.
After completing a suite, a summary of some kind would be nice:
testlogger {
showSummary true|false
}
The color in the current output is extremely useful for finding exactly which test failed while scrolling through, the summary could be an at-a-glance way to know what failed. I'm thinking the following pieces of information would be useful:
I've been putting the following in our build.gradle files, but it would be nice not to have to repeat it everywhere:
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
When using the plain
theme, the output is fine:
com.toys.OperationTest
Test testTimes() FAILED
org.opentest4j.AssertionFailedError: TIMES should multiply 2 and 3 to be 6 ==> expected: <5.0> but was: <6.0>
at com.toys.OperationTest.testTimes(OperationTest.java:20)
Test testPlus() PASSED
FAILURE: Executed 2 tests in 853ms (1 failed)
However, when using standard
or mocha
the output is:
�[0K�[1mcom.toys.OperationTest�[m
�[0K�[1m Test �[22mtestTimes()�[31m FAILED�[31m
org.opentest4j.AssertionFailedError: TIMES should multiply 2 and 3 to be 6 ==> expected: <5.0> but was: <6.0>
at com.toys.OperationTest.testTimes(OperationTest.java:20)
�[m
�[0K�[1m Test �[22mtestPlus()�[32m PASSED�[m
�[0K�[1;31mFAILURE: �[39mExecuted 2 tests in 817ms (1 failed)�[m
The run configuration for the gradle test
command specifies UTF-8 encoding.
Using Eclipse 4.9
Perform code coverage analysis using coveralls.io and display the status using a badge on the README.
Use consistent status badges from shields.io
Fix Gradle deprecation warnings
Dear Developers,
I tried to apply this plugin to my project, but unfortunately I got the following exception :
Do you have any ideas about that ?
Refresh screenshot animations to demonstrate recent capabilities. Also consider adding screenshot images.
Test logger should be configurable for each task (of type Test
of course) independently. So if a project has multiple test tasks, they should be able define different values. A typical example:
testlogger {
theme 'standard' // global
}
test {
maxParallelForks = 8
testlogger {
theme 'standard-parallel' // use a parallel theme
}
}
task functionalTest(type: Test) {
maxParallelForks = 1 // no parallelisation
testlogger {
theme 'mocha'
slowThreshold 10000 // as my functional tests are normally slow
}
include 'com/adarshr/gradle/testlogger/functional/**'
}
Currently testlogger can only be configured globally.
Allow the definition of a slow threshold value using the config DSL.
I like this plugin, but only wish it had an option to display the standard output stream.
Granted, I could add the standard Gradle-i
or --info
switch, but adds too much extra info. Is there a middle ground?
With a config like this:
testlogger {
showStandardStreams true
showPassedStandardStreams false
showSkippedStandardStreams false
showFailedStandardStreams true
}
if the test suite run itself fails - i.e. not 'a test does not pass' but the test execution failing due to something else e.g. an @Sql
setup script with an error in it - gradle fails and stderr says:
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
but there's no indication as to what the problem was. If I run again with --info
I can see that the stdout explains the problem in detail, but that disables the above testlogger filters.
Could testlogger notice the suite failure and show the output please?
Not sure if this is possible with JUnit, but I'd like to see the list of tests before they're run. I have some long test suites and knowing that the tests I want to execute will be executed is very much useful to me.
Gradle 4.7 changes the meaning displayName
and so has breaking changes for this plugin. Currently we should circumvent them as per advice received on gradle/gradle#5117.
I'm using gradle 4.6 and JUnit 5.
If I run tests using 8a70dcd I get the stacktrace below. If I go a few commits back to a9dfde0 it is fine.
No such property: displayName for class: org.gradle.api.internal.tasks.testing.DecoratingTestDescriptor
groovy.lang.MissingPropertyException: No such property: displayName for class: org.gradle.api.internal.tasks.testing.DecoratingTestDescriptor
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
at com.adarshr.gradle.testlogger.theme.StandardTheme.testText(StandardTheme.groovy:20)
at com.adarshr.gradle.testlogger.theme.Theme$testText$1.call(Unknown Source)
at com.adarshr.gradle.testlogger.logger.TestEventLogger.afterTest(TestEventLogger.groovy:62)
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy93.afterTest(Unknown Source)
at org.gradle.api.internal.tasks.testing.results.TestListenerAdapter.completed(TestListenerAdapter.java:50)
at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:230)
at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:149)
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy95.completed(Unknown Source)
at org.gradle.api.internal.tasks.testing.results.StateTrackingTestResultProcessor.completed(StateTrackingTestResultProcessor.java:71)
at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.completed(AttachParentTestResultProcessor.java:56)
at sun.reflect.GeneratedMethodAccessor114.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.FailureHandlingDispatch.dispatch(FailureHandlingDispatch.java:29)
at org.gradle.internal.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:133)
at org.gradle.internal.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:34)
at org.gradle.internal.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:73)
at org.gradle.internal.operations.BuildOperationIdentifierPreservingRunnable.run(BuildOperationIdentifierPreservingRunnable.java:39)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Upgrade both the project and the tests to use Gradle 4.4
Document system property overrides
Unicode characters are displayed as ?
on Windows (PowerShell, Command Prompt, Git Bash).
Encapsulate TestResult
and TestDescriptor
along with all their associated methods.
Would be great to have an option to show only failed tests in CI(Jenkins) build output. We have pretty big amount of tests and Jenkins output overflows several times, while at the same time in case if build failed on CI passed tests are not necessary things there. Smth. like
testLogger {
showOnlyFailedInPlainOutputMode true
}
This will work only for --console=plain
option enabled.
Also maybe legit if this flag is enabled by default for --console=plain
Fix flakey tests caused by non-deterministic test execution order
Adding the plugin to my android project throws the following error:
Cannot cast object 'task ':app:test'' with class 'org.gradle.api.DefaultTask_Decorated' to class 'org.gradle.api.tasks.testing.Test'.
Any ideas?
Upgrade to Gradle 4.9
What I expect to see:
Test thisIsASlowTestThatFailed FAILED (9.2s)
What I see:
Test thisIsASlowTestThatFailed FAILED
Upgrade to Gradle 4.5.1
Hi,
the plugin is great but I have a question regarding jUnit 5? Are you planning to support it on the future?
Thanks
Update documentation with usage instructions and GIFs for different platforms.
I like the plugin but I ran into a couple things that would be nice to have (especially during first-time use):
testLogger
eventually realized the L
is not capitalized. Maybe make both valid or just point out the difference in the documentation.These are just suggestions - feel free to close this issue if they are not something you want to pursue.
Add @CompileStatic
to more classes to improve performance
If a theme is configured by using the testlogger
DSL, it doesn't allow one to override the theme to plain by specifying --console plain
or --console=plain
.
In some of the projects I work on, they split tests up with additional source sets to allow the task to incrementally run (i.e. unitTest, integrationTest, systemTest). It would be nice if I could hook this into these other test tasks.
testlogger { testTasks ['test', 'integrationTest', 'systemTest'] }
Or optionally, hook into any Test type task by default:
tasks.withType(Test)
Erase ahead should be added to suite text
If a suite has no tests in it, it should not be printed. To reproduce, use Gradle test filtering and select a single test. Notice how all the other suites are also printed even though no tests within them are executed.
I'm not sure if this is within this project's remit, or if there's a better way to do it, but:
When a test fails I wish I'd increased app (not test) logging verbosity. But when tests are good that logging is verbose and very cluttery. Could gradle-test-logger optionally capture the running program's output (I assume slf4j is outputting to stdout) and only output it if the test fails?
Introduce a high level abstraction for collecting standard stream output which should hide the details of whether we're using a StringBuilder
or anything else internally.
In order to allow different configurations at runtime support overriding configuration by using system properties.
Publish the plugin to Gradle Central
Hello there,
Thank you very much for this nice plugin! We really need user-friendly tools like yours in the Java community!
I was looking for a way to enable printing of stdout/stderr of my tests, and everywhere I googled I was pointed at gradle Test task's testLogging.showStandardStreams
option.
But because I use gradle-test-logger-plugin
, this wasn't working. After some time it dawned on me that the issue may come from the plugin, and I was able to confirm this and then go into the documentation and see that with this plugin, one should actually use testLogger.showStandardStreams
instead.
Since this is a bit confusing, I would like to suggest that support for reading from testLogging.showStandardStreams
also be added. I believe that would a lot more predictable for people with existing test configurations, and hopefully no other users would lose a few minutes banging their heads against this small issue.
Thanks for your time! 🙏
Test failures should print more detail by default. This should be the equivalent of configuring the standard Gradle test logging with the below settings.
testLogging {
exceptionFormat "full"
showExceptions true
showCauses false
showStackTraces true
}
Upgrade plugin and tests to use Gradle 4.3
This plugin project should itself use the plugin during testing. The Circle CI config should be updated to run tests with --console=plain
after this.
Add TestNG based tests to expand the safety net.
Hi!
Here's our story: a teammate and I were trying to get your plugin working on our project. It took us a good amount of time, but we figured out why it wasn't working: the junit-platform-gradle-plugin
was preventing most of the output from this plugin.
While there is a small blurb in the documentation about that plugin being deprecated, we still had it in our build.gradle
because, I think, of some copy-pasta from older JUnit5 documentation.
It may be worth adding a note to your README that this might cause problems.
Regardless, this plugin works great! Thanks for the work you put in to it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.