As far as I know, the test related commands in gradle scripts test all cases. How can I run a particular one?
gradle test --tests ghidra.util.UnsignedDataUtilsTest.testIntLessThan
did a quick test, seems to work, taken from this SO
You could run the test in Eclipse, or via the command line. The test should pass in both, of course :crossed_fingers: .
To expand a bit more on running a single test via the cmd line:
If the test is in path "test" then the Gradle _test_ task should be used.
If it is in the path "test.slow" then use the _integrationTest_ task.
The sourceSets are defined in "./gradle/javaProject.gradle".
Some examples:
To run ghidra/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/StringTableSearchTest.java
gradle :Base:integrationTest --tests StringTableSearchTest
To run ghidra/Ghidra/Framework/Docking/src/test/java/ghidra/util/task/TaskLauncherTest.java
gradle :Docking:test --tests TaskLauncherTest.testLaunchFromSwing
The Gradle test filter (" --tests") supports pattern matching which you can read more about here.
Many times, your test does not rely on sleigh and help pages, so you could also exclude the following tasks to save time:
-x sleighCompile -x buildHelp
Also, many tests rely on a GUI component and will display windows that prevent you from using your computer while the test is running. Generally, these are in "test.slow" and part of the integrationTest task. In this case, it is useful to run Xvfb:
Xvfb :1 -screen 0 1024x768x8 -nolisten tcp
The " :1 " is your DISPLAY variable. Set your DISPLAY variable before running:
export DISPLAY=:1
Most helpful comment
You could run the test in Eclipse, or via the command line. The test should pass in both, of course :crossed_fingers: .
To expand a bit more on running a single test via the cmd line:
If the test is in path "test" then the Gradle _test_ task should be used.
If it is in the path "test.slow" then use the _integrationTest_ task.
The sourceSets are defined in "./gradle/javaProject.gradle".
Some examples:
To run ghidra/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/string/StringTableSearchTest.java
gradle :Base:integrationTest --tests StringTableSearchTestTo run ghidra/Ghidra/Framework/Docking/src/test/java/ghidra/util/task/TaskLauncherTest.java
gradle :Docking:test --tests TaskLauncherTest.testLaunchFromSwingThe Gradle test filter (" --tests") supports pattern matching which you can read more about here.
Many times, your test does not rely on sleigh and help pages, so you could also exclude the following tasks to save time:
-x sleighCompile -x buildHelpAlso, many tests rely on a GUI component and will display windows that prevent you from using your computer while the test is running. Generally, these are in "test.slow" and part of the integrationTest task. In this case, it is useful to run Xvfb:
Xvfb :1 -screen 0 1024x768x8 -nolisten tcpThe " :1 " is your DISPLAY variable. Set your DISPLAY variable before running:
export DISPLAY=:1