# Spring Boot actuator health test works from intellij, but not circleci

**URL:** <https://discuss.circleci.com/t/spring-boot-actuator-health-test-works-from-intellij-but-not-circleci/31484>\
**Category:** Build Environment\
**Created:** [July 22, 2019, 6:27pm UTC](https://discuss.circleci.com/t/spring-boot-actuator-health-test-works-from-intellij-but-not-circleci/31484 "2019-07-22T18:27:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anne](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@anne](https://discuss.circleci.com/u/anne)\
**Post date:** [July 22, 2019, 6:27pm UTC](https://discuss.circleci.com/t/spring-boot-actuator-health-test-works-from-intellij-but-not-circleci/31484/1 "2019-07-22T18:27:47Z")

</div>

Hello,

My circleci gradle build fails for the following test, when health() is called. The error says “org.junit.ComparisonFailure: expected:\<[200]\> but was:\<[503]\>”

```auto
   @LocalServerPort
   private int port;

   private String actuatorUrl(String endpoint) {
       return "http://localhost:" + port + "/actuator/" + endpoint; }

    @Test
    public void health() {
        HttpResponse response = httpClient.get(actuatorUrl("health"));

        **assertThat(response.getStatus()).isEqualTo(200);**

       assertThat(response.getBody())
                .withFailMessage("The body is " + response.getBody())
               .contains("\"UP\"");
    }

```

The build runs successfully within intellij.  
It also runs successfully form the command line “./gradlew build”.  
I’m running circleci locally, but I get the same failure if I check-in to our github repo.  
I’m using OpenJDK 11, Spring Boot 2, and Mac Mohave.

This seems to point to a circleci configuration problem, but any thoughts or ideas are greatly appreciated.

Thanks,  
Anne

---

<div class="post-metadata">

**Author:** ![excenter](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/excenter/32/18610_2.png) [@excenter](https://discuss.circleci.com/u/excenter)\
**Post date:** [July 24, 2019, 2:06pm UTC](https://discuss.circleci.com/t/spring-boot-actuator-health-test-works-from-intellij-but-not-circleci/31484/2 "2019-07-24T14:06:53Z")

</div>

> “org.junit.ComparisonFailure: expected:\<[200]\> but was:\<[503]\>”

Looks like the service isn’t up to respond 200 yet when you assert your test.  
A thing I do in my tests using npx is to `wait-on` the service before running, which might be functionally similar to what you need to do.  
Ignoring the health check does it work and respond as you’d expect?

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [July 24, 2019, 6:03pm UTC](https://discuss.circleci.com/t/spring-boot-actuator-health-test-works-from-intellij-but-not-circleci/31484/3 "2019-07-24T18:03:19Z")

</div>

It looks like your code could do with a bit of formatting. That will help folks helping you with your immediate problem, and also will aid readers looking at posts here in the future. Would you edit your post to fix this?

The Markdown syntax for code formatting is:

````
```
code goes here
```
````

---

<div class="post-metadata">

**Author:** ![anne](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@anne](https://discuss.circleci.com/u/anne)\
**Post date:** [July 24, 2019, 7:02pm UTC](https://discuss.circleci.com/t/spring-boot-actuator-health-test-works-from-intellij-but-not-circleci/31484/4 "2019-07-24T19:02:24Z")

</div>

Thank you, I blocked the code with ```.

---

<div class="post-metadata">

**Author:** ![anne](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@anne](https://discuss.circleci.com/u/anne)\
**Post date:** [July 24, 2019, 7:04pm UTC](https://discuss.circleci.com/t/spring-boot-actuator-health-test-works-from-intellij-but-not-circleci/31484/5 "2019-07-24T19:04:44Z")

</div>

Thank you! I think this is the problem. The test is running before the service starts in circleci. I’m working on refactoring the workflow.  
It was working locally because intellij bootstrap starts the service even to run just one test, then shuts it down.
