7

Our test suite takes 5 minutes to run (mostly due to Kafka containers being setup before each test I presume).

When running mvn quarkus:dev and working on a test, I don't know how to re-run only a single test, the one I'm working on.

If my test is broken, and is the only one broken, then it is fine. But as soon as it turns green, quarkus will not run it again if I change the test code. If I am making big changes, quarkus will run all broken tests and I cannot clearly follow the result of the test I am working on.

I can use mvn verify to run a single test, but the compilation time and application startup times makes it too boring and breaks the mental flow.

How can I tell quarkus to run only some specific test while running?

lud
  • 1,941
  • 20
  • 35
  • Are you talking about continuous testing here? – geoand Jan 06 '22 at 06:15
  • @geoand yes this is about running a single test while running continuous testing. – lud Jan 06 '22 at 09:03
  • Continuous testing automatically figures out which tests need to be run based on what was changed – geoand Jan 07 '22 at 07:09
  • 2
    Sometimes it's still useful to run just one test, even if multiple tests should run based on what's changed. It's useful to reduce noise in the logs and/or isolate things. – Holly Cummins Aug 12 '22 at 13:07

2 Answers2

1

You cannot run a single test in continuous testing with Quarkus alone; it determines which tests to run. However, you can run a single test using the following command:

mvn test -Dtest="TestClassName#TestMethodName"

Note that this command will compile the entire project again.

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.domain.TestClassName
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 55.259 s - in com.domain.TestClassName
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

Another option is to run it through IntelliJ IDEA’s run configuration.

Borislav Gizdov
  • 1,323
  • 12
  • 22
1

Quarkus Dev mode has some neat options that may help you. Just run mvn quarkus:dev and let him test. Then if you have a failing test you can enable "broken only" mode by hitting 'b', this will run only broken tests until you disable it by hitting 'b' again. Check out the help by hitting 'h' for more fancy shit.

If you want to manually run only broken tests, instead of r (for re-run) hit 'f' (for re-run failed tests).

This will boost your productivity and makes you smile (if it works for you).

KnechtRootrecht
  • 447
  • 4
  • 8