In a Spring Boot Maven project I have tests with JUnit 5
.
Within a test class (annotated with @SpringBootTest
) I can select
Test File
Debug Test File
Run Focused Test Method
Debug Focused Test Method
On the project itself (Files
window) I can select
Test
which runs all tests.
Is there a way to debug all tests?
So to speak I would expect a selection on the project like Debug Test
besides Test
.
The reason is, that some errors appear only when I run all tests. But when I run or debug just the erroneous test method or even the whole test class, the errors don't appear.
Sorry I haven't found a more GUI-friendly way yet (and verified only on Netbeans 12.3), but:
a) If you already have a nbactions.xml
:
Add the following to the <actions/>
element:
<action>
<actionName>CUSTOM-Debug-all-tests</actionName> <!-- should be unique for this project -->
<displayName>Debug All Tests</displayName> <!-- will be displayed in context menu -->
<packagings>
<packaging>*</packaging> <!-- according to your needs, taken from pre-configured action -->
</packagings>
<goals> <!-- according to your needs, taken from pre-configured action -->
<goal>process-test-classes</goal>
<goal>surefire:test</goal>
</goals>
<properties> <!-- according to your needs, taken from pre-configured action -->
<forkMode>once</forkMode>
<maven.surefire.debug>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}
</maven.surefire.debug>
<jpda.listen>true</jpda.listen>
</properties>
</action>
(Of course you can modify & adjust it to your needs, but this works for a quickstart (maven) project. Also interesting: "Debug integration test" action!)
Then you can execute it from "Project context menu>Run Maven>Debug All Tests"!
b) If You don't have an nbactions.xml
(in your project) yet:
Just modify one of the pre-configured "Actions" (preferably "Debug (Integration) Test") from the "Actions" menu of "Project Properties", this (hitting "OK") will generate the according file at your project root. Then you can make it (maven-) executable as described above (a).(There must/should also be a way to run these Actions without modifying nbactions.xml
at least by implementing a custom plugin....but haven't found the action/menu/tab yet:))