 (defun erlang-eunit-test-generator-p (test-name)
   (if (erlang-eunit-string-match-p "^\\(.+\\)_test_$" test-name) t nil))
 
-;;; Run the current EUnit test
-(defun erlang-eunit-run-current-test ()
-  (let* ((module-name (erlang-add-quotes-if-needed
-                       (erlang-eunit-module-name buffer-file-name)))
-         (test-name (erlang-eunit-test-name))
-         (command
-          (cond ((erlang-eunit-simple-test-p test-name)
-                 (format "eunit:test({%s, %s}%s)."
-                         module-name test-name (erlang-eunit-opts)))
-                ((erlang-eunit-test-generator-p test-name)
-                 (format "eunit:test({generator, %s, %s}%s)."
-                         module-name test-name (erlang-eunit-opts)))
-                (t
-                 (format "%% WARNING: '%s' is not a test function"
-                         test-name)))))
+;;; Run one EUnit test
+(defun erlang-eunit-run-test (module-name test-name)
+  (let ((command
+         (cond ((erlang-eunit-simple-test-p test-name)
+                (format "eunit:test({%s, %s}%s)."
+                        module-name test-name (erlang-eunit-opts)))
+               ((erlang-eunit-test-generator-p test-name)
+                (format "eunit:test({generator, %s, %s}%s)."
+                        module-name test-name (erlang-eunit-opts)))
+               (t (format "%% WARNING: '%s' is not a test function" test-name)))))
+    (erlang-eunit-record-recent 'test-mode module-name test-name)
     (erlang-eunit-inferior-erlang-send-command command)))
 
 ;;; Run EUnit tests for the current module
-(defun erlang-eunit-run-module-tests ()
-  (let* ((module-name (erlang-add-quotes-if-needed
-                       (erlang-eunit-source-module-name buffer-file-name)))
-         (command (format "eunit:test(%s%s)." module-name (erlang-eunit-opts))))
+(defun erlang-eunit-run-module-tests (module-name)
+  (let ((command (format "eunit:test(%s%s)." module-name (erlang-eunit-opts))))
+    (erlang-eunit-record-recent 'module-mode module-name nil)
     (erlang-eunit-inferior-erlang-send-command command)))
+
+(defun erlang-eunit-compile-and-run-recent ()
+  "Compile the source and test files and repeat the most recent EUnit test run.
+
+With prefix arg, compiles for debug and runs tests with the verbose flag set."
+  (interactive)
+  (case (erlang-eunit-recent 'mode)
+    ('test-mode
+     (erlang-eunit-compile-and-test
+      'erlang-eunit-run-test (list (erlang-eunit-recent 'module)
+                                   (erlang-eunit-recent 'test))))
+    ('module-mode
+     (erlang-eunit-compile-and-test
+      'erlang-eunit-run-module-tests (list (erlang-eunit-recent 'module))
+      (erlang-eunit-recent 'cover)))
+    (t (error "EUnit has not yet been run.  Please run a test first."))))
 
 (defun erlang-eunit-cover-compile ()
   "Cover compile current module."

  '(("\C-c\C-et" erlang-eunit-toggle-src-and-test-file-other-window)
    ("\C-c\C-ek" erlang-eunit-compile-and-run-module-tests)
    ("\C-c\C-ej" erlang-eunit-compile-and-run-current-test)
    ("\C-c\C-ec" erlang-eunit-compile-and-run-module-tests-under-cover)
    ("\C-c\C-ev" erlang-eunit-cover-compile)
    ("\C-c\C-ea" erlang-eunit-analyze-coverage)))

	   (if (file-readable-p test-filename)
	       (erlang-eunit-compile-file test-filename)
	     t)
           (apply test-fun test-args)
           (if under-cover
               (save-excursion
                 (set-buffer (find-file-noselect src-filename))
