Skip to content

Live reload is not working for tests #43432

@rcsim

Description

@rcsim

Describe the bug

During a workshop using the https://quarkus.io/quarkus-workshops/super-heroes/ , I followed the steps but got an error when I changed the Endpoint Resource and Test and ran the tests without re-launching the application.

Expected behavior

As per the Live Reload feature, after changing the test files to match the resource file, tests would pass without the need to relaunch the application.

Actual behavior

It is needed to fully relaunch the application to the test pass.

How to Reproduce?

Steps:
1- Create the rest-villains REST project.
2- Run the project in dev mode (./mvnw quarkus:dev).
3- Verify Endpoit is returning the String "Hello from Quarkus REST".
4- Change the String at VillainResource to "Hello Villain Resource"
5- Verify Endpoit returns the String "Hello from Quarkus REST" without relaunching the application.
6- Run the tests using "r" in develop mode, testing is failing as expected.
7- Change the String at VillainResourceTest.
8- Run the tests again using "r" in develop mode, testing is failing but this time it is expected to pass and the Strings at VillainResource and VillainResourceTest match.

How to recover:
1- Relaunch the application ( stop and run ./mvnw quarkus:dev), now the test passes.

Output of uname -a or ver

Linux rcsim-p52 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 GNU/Linux

Output of java -version

java version "17.0.12" 2024-07-16 LTS Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286) Java HotSpot(TM) 64-Bit Server VM (build 17.0.12+8-LTS-286, mixed mode, sharing)

Quarkus version or git rev

(Quarkus Main Thread) rest-villains 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.15.0)

Build tool (ie. output of mvnw --version or gradlew --version)

Maven home: /home/rcsim/Workspace/tools/maven/apache-maven-3.9.6 Java version: 17.0.12, vendor: Oracle Corporation, runtime: /mnt/c/Users/rcsim/Workspace/tools/jdk/jdk-17.0.12 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.15.153.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"

Additional information

Logs from the terminal:

`2024-09-22 10:46:33,296 ERROR [io.qua.test] (Test runner thread) ==================== TEST REPORT #3 ====================
2024-09-22 10:46:33,297 ERROR [io.qua.test] (Test runner thread) Test VillainResourceTest#testHelloEndpoint() failed
: java.lang.AssertionError: 1 expectation failed.
Response body doesn't match expectation.
Expected: is "Hello from Quarkus REST"
Actual: Hello Villain Resource

    at io.restassured.internal.ValidatableResponseOptionsImpl.body(ValidatableResponseOptionsImpl.java:238)
    at io.quarkus.workshop.superheroes.villain.VillainResourceTest.testHelloEndpoint(VillainResourceTest.java:17)

2024-09-22 10:46:33,297 ERROR [io.qua.test] (Test runner thread) >>>>>>>>>>>>>>>>>>>> Summary: <<<<<<<<<<<<<<<<<<<<
io.quarkus.workshop.superheroes.villain.VillainResourceTest#testHelloEndpoint(VillainResourceTest.java:17) VillainResourceTest#testHelloEndpoint() 1 expectation failed.
Response body doesn't match expectation.
Expected: is "Hello from Quarkus REST"
Actual: Hello Villain Resource
2024-09-22 10:46:33,298 ERROR [io.qua.test] (Test runner thread) >>>>>>>>>>>>>>>>>>>> 1 TEST FAILED <<<<<<<<<<<<<<<<<<<<`

Force Restart and test again (Still Failing):
`2024-09-22 10:59:57,307 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (Aesh InputStream Reader) Restarting as requested by the user.

2024-09-22 10:59:57,318 INFO [io.quarkus] (Quarkus Main Thread) rest-villains stopped in 0.010s


--/ __ / / / / _ | / _ / /// / / / __/
-/ /
/ / // / __ |/ , / ,< / // /\
--___
// |//|//||_//
2024-09-22 10:59:57,746 INFO [io.quarkus] (Quarkus Main Thread) rest-villains 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.15.0) started in 0.423s. Listening on: http://localhost:8080

2024-09-22 10:59:57,747 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.

2024-09-22 10:59:57,748 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, rest, rest-jackson, smallrye-context-propagation, vertx]

2024-09-22 10:59:57,749 INFO [io.qua.dep.dev.RuntimeUpdatesProcessor] (Aesh InputStream Reader) Live reload total time: 0.502s

2024-09-22 11:00:03,211 ERROR [io.qua.test] (Test runner thread) ==================== TEST REPORT #4 ====================
2024-09-22 11:00:03,212 ERROR [io.qua.test] (Test runner thread) Test VillainResourceTest#testHelloEndpoint() failed
: java.lang.AssertionError: 1 expectation failed.
Response body doesn't match expectation.
Expected: is "Hello from Quarkus REST"
Actual: Hello Villain Resource

    at io.restassured.internal.ValidatableResponseOptionsImpl.body(ValidatableResponseOptionsImpl.java:238)
    at io.quarkus.workshop.superheroes.villain.VillainResourceTest.testHelloEndpoint(VillainResourceTest.java:17)

2024-09-22 11:00:03,212 ERROR [io.qua.test] (Test runner thread) >>>>>>>>>>>>>>>>>>>> Summary: <<<<<<<<<<<<<<<<<<<<
io.quarkus.workshop.superheroes.villain.VillainResourceTest#testHelloEndpoint(VillainResourceTest.java:17) VillainResourceTest#testHelloEndpoint() 1 expectation failed.
Response body doesn't match expectation.
Expected: is "Hello from Quarkus REST"
Actual: Hello Villain Resource
2024-09-22 11:00:03,212 ERROR [io.qua.test] (Test runner thread) >>>>>>>>>>>>>>>>>>>> 1 TEST FAILED <<<<<<<<<<<<<<<<<<<<`

Stop and Run the application again:
`2024-09-22 11:07:26,931 INFO [io.quarkus] (Shutdown thread) rest-villains stopped in 0.002s

--
Press [e] to edit command line args (currently ''), [r] to resume testing, [o] Toggle test output, [:] for the terminal, [h] for more options>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23:54 min
[INFO] Finished at: 2024-09-22T11:07:27-03:00
[INFO] ------------------------------------------------------------------------
rcsim@rcsim-p52:~/Workspace/learning/quarkus/workshop/quarkus-super-heroes/super-heroes/rest-villains$ ./mvnw quarkus:dev
[INFO] Scanning for projects...
[INFO]
[INFO] -----------< io.quarkus.workshop.super-heroes:rest-villains >-----------
[INFO] Building rest-villains 1.0.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- quarkus:3.15.0:dev (default-cli) @ rest-villains ---
[INFO] Invoking resources:3.3.1:resources (default-resources) @ rest-villains
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Invoking quarkus:3.15.0:generate-code (default) @ rest-villains
[INFO] Invoking compiler:3.13.0:compile (default-compile) @ rest-villains
[INFO] Nothing to compile - all classes are up to date.
[INFO] Invoking resources:3.3.1:testResources (default-testResources) @ rest-villains
[INFO] skip non existing resourceDirectory /mnt/c/Users/rcsim/Workspace/learning/quarkus/workshop/quarkus-super-heroes/super-heroes/rest-villains/src/test/resources
[INFO] Invoking quarkus:3.15.0:generate-code-tests (default) @ rest-villains
[INFO] Invoking compiler:3.13.0:testCompile (default-testCompile) @ rest-villains
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 2 source files with javac [debug parameters release 17] to target/test-classes
Listening for transport dt_socket at address: 5005


--/ __ / / / / _ | / _ / /// / / / __/
-/ /
/ / // / __ |/ , / ,< / // /\
--___
// |//|//||_//
2024-09-22 11:07:46,023 INFO [io.quarkus] (Quarkus Main Thread) rest-villains 1.0.0-SNAPSHOT on JVM (powered by Quarkus 3.15.0) started in 2.419s. Listening on: http://localhost:8080

2024-09-22 11:07:46,026 INFO [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated.
2024-09-22 11:07:46,026 INFO [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, rest, rest-jackson, smallrye-context-propagation, vertx]

--
All 1 test is passing (0 skipped), 1 test was run in 3029ms. Tests completed at 11:07:53.
Press [e] to edit command line args (currently ''), [r] to re-run, [o] Toggle test output, [:] for the terminal, [h] for more options>`

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions