# Build successful while test fails

**URL:** <https://discuss.gradle.org/t/build-successful-while-test-fails/2438>\
**Category:** Old Forum Archive\
**Created:** [September 17, 2014, 9:09am UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438 "2014-09-17T09:09:00Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![erik\_pragt](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@erik\_pragt](https://discuss.gradle.org/u/erik_pragt)\
**Post date:** [September 17, 2014, 9:09am UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/1 "2014-09-17T09:09:00Z")

</div>

Sorry, the buffer of my terminal got lost, and I only have this left. The rest can be found here: [https://twitter.com/epragt/status/512163337430638592](https://twitter.com/epragt/status/512163337430638592)

```gradle
at com.esotericsoftware.kryo.io.Input.readByte(Input.java:255)
 at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:64)
 at org.gradle.messaging.remote.internal.hub.InterHubMessageSerializer$MessageReader.read(InterHubMessageSerializer.java:53)
 at org.gradle.messaging.remote.internal.inet.SocketConnection.receive(SocketConnection.java:83)
 ... 5 more
  8 tests completed, 1 failed
:check
:build
  BUILD SUCCESSFUL

```

This happened while running a test, the test executor stopped, giving the above stacktrace. When doing another ‘gradlew build’, the execution was immediately successful, even though I have one failing test case, which showed up again after doing a ‘gradlw clean build’.

---

<div class="post-metadata">

**Author:** ![Andrey\_Hihlovskiy](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/andrey_hihlovskiy/32/201_2.png) [@Andrey\_Hihlovskiy](https://discuss.gradle.org/u/Andrey_Hihlovskiy)\
**Post date:** [September 17, 2014, 9:21am UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/2 "2014-09-17T09:21:00Z")

</div>

I will try to reproduce the problem on the simplest setup: gradle + java-app + junit. Then we go step by step to isolating the problem.

---

<div class="post-metadata">

**Author:** ![Andrey\_Hihlovskiy](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/andrey_hihlovskiy/32/201_2.png) [@Andrey\_Hihlovskiy](https://discuss.gradle.org/u/Andrey_Hihlovskiy)\
**Post date:** [September 17, 2014, 9:34am UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/3 "2014-09-17T09:34:00Z")

</div>

I created the simplest project, allowing to test gradle + junit: [https://github.com/akhikhl/testtest](https://github.com/akhikhl/testtest)

Please do: - ‘git clone [https://github.com/akhikhl/testtest.git](https://github.com/akhikhl/testtest.git)’ - ‘cd testtest’ - ‘gradle build’

Does it show “BUILD FAILED” for you?

---

<div class="post-metadata">

**Author:** ![erdi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/erdi/32/24_2.png) [@erdi](https://discuss.gradle.org/u/erdi)\
**Post date:** [September 17, 2014, 10:14am UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/4 "2014-09-17T10:14:00Z")

</div>

Erik,

Is your code public? If not, would it be possible to make it public? We will need to have a look at it to be able to investigate.

Based on what information is available in the stacktrace I can tell that the buffer underflow you’re seeing is some kind of a problem with communication between the build process and the worker process running the tests. Having a look at the code will probably reveal more.

---

<div class="post-metadata">

**Author:** ![Andrey\_Hihlovskiy](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/andrey_hihlovskiy/32/201_2.png) [@Andrey\_Hihlovskiy](https://discuss.gradle.org/u/Andrey_Hihlovskiy)\
**Post date:** [September 17, 2014, 10:17am UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/5 "2014-09-17T10:17:00Z")

</div>

Does com.esotericsoftware.kryo.io.Input communicate to gradle classes? If not, maybe it is using the same ports?

---

<div class="post-metadata">

**Author:** ![erik\_pragt](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@erik\_pragt](https://discuss.gradle.org/u/erik_pragt)\
**Post date:** [September 17, 2014, 1:18pm UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/6 "2014-09-17T13:18:00Z")

</div>

Hi guys, I’m actually able to reproduce it, in a very nasty way.

I have a project with a failing test. What I also have, is another test, with a Thread.sleep(10000) in it, which first opens a Swing console, and then starts waiting. I forgot that the code was there, and thought my system was hanging or something. So what I did was:

1. ./gradlew build 2) the first test fails 3) the second test seems to hang, so I pressed CMD+Q 4) result:

```gradle
nl.jworks.color.DominantColorFinderTest > testTwoColors FAILED
    java.lang.AssertionError at DominantColorFinderTest.java:27
  8 tests completed, 1 failed
  BUILD SUCCESSFUL

```

I can share the code, but I rather not put it on Github, because right now it’s not hubworthy.

---

<div class="post-metadata">

**Author:** ![jengels](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jengels/32/159_2.png) [@jengels](https://discuss.gradle.org/u/jengels)\
**Post date:** [September 17, 2014, 2:25pm UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/7 "2014-09-17T14:25:00Z")

</div>

Do you get the same stacktrace from above? The one with the org.gradle.messaging.remote stuff in it? I bet what’s happening is the worker running the tests is dying before it sends the results back to the main thread. That’s then getting interpreted as ‘no errors’ which is marking the build as success.

---

<div class="post-metadata">

**Author:** ![erik\_pragt](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@erik\_pragt](https://discuss.gradle.org/u/erik_pragt)\
**Post date:** [September 17, 2014, 5:41pm UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/8 "2014-09-17T17:41:00Z")

</div>

Hi John,

Also thanks for the reply! Yes, I get indeed the same error. It makes sense that it works like that, but from a user perspective, it’s a bit weird. I mean, I assume the build systems knows that it kicked off the test to start with, and interpreting ‘no results’ as ‘everything is fine’ is a bit unexpected, but I might be totally having the wrong idea here. Anyway, it’s not so important, though I’m curious if there are other scenarios where this might be a problem. If not, then just close this issue, I’d say.

---

<div class="post-metadata">

**Author:** ![jengels](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jengels/32/159_2.png) [@jengels](https://discuss.gradle.org/u/jengels)\
**Post date:** [September 17, 2014, 5:44pm UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/9 "2014-09-17T17:44:00Z")

</div>

I agree that that is odd and if that is in fact what is happening, it’s probably a bug that should be fixed. The more curious question is why you’re test seems to be killing the worker.

---

<div class="post-metadata">

**Author:** ![erik\_pragt](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@erik\_pragt](https://discuss.gradle.org/u/erik_pragt)\
**Post date:** [September 17, 2014, 5:46pm UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/10 "2014-09-17T17:46:00Z")

</div>

I think that’s because I am not killing my Swing UI, which is popping up, but instead it seems I’m killing GradleWorkerMain.

---

<div class="post-metadata">

**Author:** ![jengels](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jengels/32/159_2.png) [@jengels](https://discuss.gradle.org/u/jengels)\
**Post date:** [September 17, 2014, 6:05pm UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/11 "2014-09-17T18:05:00Z")

</div>

You doing a System.exit(0) or something like that?

---

<div class="post-metadata">

**Author:** ![erik\_pragt](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@erik\_pragt](https://discuss.gradle.org/u/erik_pragt)\
**Post date:** [September 17, 2014, 6:52pm UTC](https://discuss.gradle.org/t/build-successful-while-test-fails/2438/12 "2014-09-17T18:52:00Z")

</div>

Something like that. Cmd+Q, which I think is (almost?) equal to System.exit(). I did it because I thought my test was hanging, then this happened.
