4343; ; Set to non-nil to use TestNG instead of the default JUnit
4444(defvar dap-java-use-testng nil )
4545
46+ (defvar dap-java--latest-test nil )
47+
4648(defcustom dap-java-java-command " java"
4749 " Path of the java executable."
4850 :group 'dap-java
@@ -278,9 +280,17 @@ surrounding method. Otherwise it will run the surronding test."
278280 " Run JUnit test.
279281If there is no method under cursor it will fallback to test class."
280282 (interactive )
281- (-> (dap-java--run-unit-test-command dap-java-java-command t )
282- (plist-put :skip-debug-session t )
283- dap-start-debugging))
283+ (setq dap-java--latest-test
284+ (-> (dap-java--run-unit-test-command dap-java-java-command t )
285+ (plist-put :skip-debug-session t )))
286+ (dap-start-debugging dap-java--latest-test))
287+
288+ (defun dap-java-run-last-test ()
289+ " Run again latest class/method test"
290+ (interactive )
291+ (if dap-java--latest-test
292+ (dap-start-debugging dap-java--latest-test)
293+ (message " No previous tests to rerun " )))
284294
285295(defun dap-java-debug-test-method (port )
286296 " Debug JUnit test.
@@ -303,9 +313,10 @@ attaching to the test."
303313(defun dap-java-run-test-class ()
304314 " Run JUnit test."
305315 (interactive )
306- (-> (dap-java--run-unit-test-command dap-java-java-command nil )
307- (plist-put :skip-debug-session t )
308- dap-start-debugging))
316+ (setq dap-java--latest-test
317+ (-> (dap-java--run-unit-test-command dap-java-java-command nil )
318+ (plist-put :skip-debug-session t )))
319+ (dap-start-debugging dap-java--latest-test))
309320
310321(defun dap-java-debug-test-class (port )
311322 " Debug JUnit test class.
0 commit comments