I'm using Serenity and Cucumber with Spring for Dependency Injection support. The test steps are running smoothly and quite fast on IntelIJ (something about 12 minutes).
However, when I run the tests from command line with mvn clean verify, the tests run very very very slow and it outputs byte code such as below:
16:30:32.419 [main] DEBUG org.apache.http.wire - >> "}[0x13][0x98][0x13][0x16]$[0xc][0xf7]z[0x8a][0x19]6F[0x8c][0xc4]U[0x86][0xdc]0+[0xb0][0x1][0xe6](e[0xed][0xc9]9[0xd8][0xba][\r][0xde] [0xa7]U[0x98][0xcb]1[0xc7][0xaf][0xf3]4M8[0xa7][0xc7]_n[0x3]^[0xe7][0x9f]`#[0xd2]WHf*[0xc]8[0xff]U[0x92]!e[0xc1]%[0xb0][0x86][0x1b][0xc0][0xf5]0[0xd6]S[0xf3]m[0xe0]o[0xb6][0x94][0xbd][0x0][0xe2][0x98]~[0xf4]7[0xc][0xb4][0xa5][0xfd][0xdb][0xc7]C[0x92][0xce][0x85]~P[0xa8]W[0xe5][0xf3][0x8a]~[0xf3][0xbf][0xb][0x14][0xdf]2[0xd4]Y[[0x96]A}[0x95][0xfe][0xea][0x9][0x8f][0xfd][0xa5][0xc][0xf1]~[0xb0][0xd1][0xa4][0xe1]F[0x13][0xa6]+[0xf6][0x18][0xca][0xeb][0xfc]~.1[0xd3]*[0x90][0x84][0xd4][0xec][0xc]u$[0xe4]spY[0xcf][0x11][0xc0]e[0xfa][0x2]2[0x9]a2[0x86][0xb1][0x8d][0xf2]P[0xe][0x81][0x18]C[0xa1][0xd0][0x1f][\r][0xd8][0xe3][0x95]5[0xf6][0x0][0xd3]$[0xd6][0x13][0xc1][0x94][0x3]h[0xf5]U[0x12][0xf9][0xa9]#&y[0x9a]8q][0x99][0xb7][0xe2]$[0xd7][0xf1][0x84][0x9d]\[0xfe][0xa2][0xcd]0[0xd4]?^_[0x99][0xc8][0xd1][0xc4]+[0x86][0xb4]L[0x4][0xfb][0x9a][\r][0x8f][0xa0]Dd[0xb2][0x8]8[0x3][0xbb];[0xa2]`[0xec][0xcc][0xfe]u[0x18]>[0xe5][0xea][0xa1][0x5][0xb4][0x11]Urc([0xa5][0xac][0xf0]t[0x18][0xc3]i[0xc][0xa6]v[0x9d]n[0x89][0xb3][0x9c][0x15],y[0xc8][0x15][0xdf][0xf8][0x8a]>[0x13]G[0xaf]N[0xe1]AD<<L[0xcc][0xe5]q[0xd9]T[0xe]a\[0xf1][0x19][0xdb][0x1f]w[0x4][0xd3][0xf0][0xa8][0x88][0xfd]P[0xda][0xf][0x90][0xd4]y[0xea][0x87][0xf8][0xaa]_[0xa2]J[0x6][0x93]R[0xb6][0x8d]x{~f#=[0x93][0xf0][0xe4][0xc3]X[0x19][0xde][0x96]E[0x1a][0xfa][0x0]+[0x4][0xe8][0x3][0x11][\n]"
Has anyone ever encountered similar behaviour? If so, what can be done about this?
Thank you in advance.
Check if you've got debug logging on somewhere when running with maven. The sheer amount of information logged at debug level will slow down your machine
The comment by #mrkorstanje is the solution. I managed to disable Spring loggings and the tests run as expected now.
Related
I got java cucumber + serenity project in Intellij
I configured the maven run configure:
Working directory: xxxxx
Command line: clean verify "xxxxx"
The run configure works fine before, I can use it run test as well as fire up the debug mode.
However, one of sudden, I cannot run the debug mode anymore. Even though I clicked the debugged button (green little bug) it never stops at the break point.
It still stops if I added break point to java.lang Object class, but it never stops at any break point from actual test methods, very weird...any one can help? Thanks
Surefire starts a new jvm to run tests (a fork). You are debugging the jvm that starts the second jvm, not the jvm that runs the tests.
Either change the fork mode or attach a debugger to the forked jvm.
http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html
I'm working on a SpringBoot test which fails to launch any test case apparently as a side effect of the springboot context being modified with additional beans.
Initially, the test cases from CreateServiceKeyBindingComponentTest are detected properly by idea 2019.3/gradle 6.0.1/junit 5.5.2/springboot 2.2.4, and properly execute.
With some additional beans loaded in the context, see diff from commit 33ead9, the test suprisingly fails with the following message, and no detected test case
> Task :spring-cloud-app-broker-integration-tests:testClasses UP-TO-DATE
> Task :spring-cloud-app-broker-integration-tests:test FAILED
Test result: SUCCESS
Test summary: 0 tests, 0 succeeded, 0 failed, 0 skipped
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':spring-cloud-app-broker-integration-tests:test'.
> No tests found for given includes: [org.springframework.cloud.appbroker.integration.CreateServiceKeyBindingComponentTest](filter.includeTestsMatching)
What troubleshooting steps can be used in gradle/junit/springboot-context to fix such unexpected "No tests found" symptom ?
This looks similar to #SpringBootTest resulting in 'No tests found for given includes' which did not provide diagnostics
I tried the following approaches without luck
0- intellij stop and checking no gradle daemon was still running, before restarting intellij
1- specifying --debug in gradle argument to get debug output did not provide useful logs
2020-03-11T18:07:07.042+0100 [DEBUG] [TestEventLogger] Gradle Test Run :spring-cloud-app-broker-integration-tests:test STARTED
2020-03-11T18:07:07.052+0100 [QUIET] [system.out]
2020-03-11T18:07:07.052+0100 [QUIET] [system.out] Test result: SUCCESS
2020-03-11T18:07:07.052+0100 [QUIET] [system.out] Test summary: 0 tests, 0 succeeded, 0 failed, 0 skipped
2020-03-11T18:07:07.052+0100 [QUIET] [system.out]
2020-03-11T18:07:07.053+0100 [QUIET] [system.out] </event></ijLog>
2020-03-11T18:07:07.053+0100 [DEBUG] [TestEventLogger]
2020-03-11T18:07:07.053+0100 [DEBUG] [TestEventLogger] Gradle Test Run :spring-cloud-app-broker-integration-tests:test PASSED
2- trying to naively display springboot verbose log using logback did not produce further logs (see full diff)
<logger name="org.springframework.test.context.junit.jupiter" level="debug" />
<logger name="org.springframework.boot.test" level="debug" />
3- trying to run the test with intellij instead of gradle leads to no further output (see related Intelij 2019.1 update breaks JUnit tests)
java ... com.intellij.rt.execution.application.AppMainV2 com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit5 org.springframework.cloud.appbroker.integration.CreateServiceKeyBindingComponentTest
##teamcity[enteredTheMatrix]
##teamcity[treeEnded]
Full list of other diagnostics considered in log file along with associated commits
EDIT
The "no tests found..." error suddenly disappeared after being consistently being reproductible by adding/removing the offending beans in the spring context. I'm unable to reproduce it anymore nor to clearly identify what fixed it in my environment :-(
Here are in between steps that I ran even through they seem unrelated and I don't explain how they could have influenced/fixed the issue:
0- the update of springboot/junit/gradle in commit d9fda3 which would not have properly be reloaded by intellij/gradle daemon
1- passing the --scan option to the gradle build (which produces a build scan)
A build scan is a shareable and centralized record of a build that provides insights into what happened and why.
2- turning on the intellij Enable Gradle script debugging option
3- run the gradle build within Idea debugger by hitting "Debug" on the gradle configuration
4- stopping the gradle daemon with ./gradlew --stop
Running a gradle clean at the top level project finally solved the issue for me (once it reproduced again).
Notes of further unsuccessfull attempts:
A gradle cleanat the subproject level (of this multi module project)
Executing test using intellij runner instead of gradle runner
Exiting the gradle daemon with ./gradlew -stop
One common reason why the tests are not found is because the test runner is missing or the wrong version is used.
If you are using Gradle, you must have one of the following lines in the dependencies block of your build.gradle:
for JUnit 4: testRuntimeOnly('org.junit.vintage:junit-vintage-engine')
for JUnit 5: testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine')
Source = JUnit 5 User Guide - Running Tests
This does not answer directly the question but might help with troubleshooting the issue.
I want to run my app as a windows service so i modified my pom to include
executable / true.
I tried "mvn clean install" - after a few moments, it starts doing tests but after more than 3 hours it shows only messages about websocket. I have websocket in my project, but what is the problem? Why the long running time ? Am i missing something ?
EDIT: I'm sorry about the picture, i thought the image would say more than i could say.
The only thing new about my project is the "executable - true " in the pom. I removed it and tried mvn clean install with another failure. I am thinking it has something to do with my mvn packages ? I am starting to remove them one by one to identify the source.
EDIT2: I found the source: removing websocket dependency completes mvn clean install in under 2 minutes. What is the message? Is it something wrong with my websocket ? It is the spring-boot-starter-websocket dependency.
I don't understand, why running the app in intellij works and mvn clean install doesn't ?
After simulating on a local project i believe that a local test is keeping the connection open and won't let spring finish.
Check the test and first uncomment it to isolate the problem.
Every build takes an extra 3-4 seconds, pausing immediately after the log output prints the following.
[LIFECYCLE]
[org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices] Forcing
System.gc()
Why is it "forcing" this? How do I avoid this and speed up my build?
I've looked into this, and this is a consequence of having Gradle's debug-level logging enabled (eg. gradle --debug assemble).
Run Gradle without debug logging enabled (eg. gradle --info assemble) and this should not occur anymore.
References: libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinGradleBuildServices.kt
Kotlin Gradle plugins calls System.gc before and after a build only when debug logging is enabled (Gradle is run with -d or --debug command line argument).
Users do not normally run Gradle with debug logging enabled because it is extremely noisy and slow, so forcing a GC is a relatively minor issue.
Historically this behaviour was added to test against memory leaks when Gradle daemon is enabled. The idea was to log a difference of used memory before and after a build, run a few builds consequently in a test, and assert that the difference is not exceeding the threshold.
I think calling System.gc should be avoided unless the test KotlinGradleIT#testKotlinOnlyDaemonMemory is running, so I've created an issue at Kotlin bugtracker https://youtrack.jetbrains.com/issue/KT-17960
So I've managed to get jasmine maven plugin to work with maven and our js unit test.
All is running well, but i found when there's a test that failed, bamboo will say it failed, but the error is "No failed tests found, possible compilation error ocurred".
I've tried to get it to parse TEST-jasmine.xml result by specifically specify the folder JUnit parser needed, and get jasmine to write to that folder using jasmineTargetDir tag in pom.xml, but it's still not finding the right result. Jasmine faithfully write the test result to the folder, but seemingly JUnit is not parsing it?
Any clue as to why and how to solve the issue?
Running on Bamboo v 5.14.3.1 I've configured the Maven task of Default Stage to search for test result files:
And then produced fake failing test. After that the build failed with failing test:
Hope this helps