Unit-testing
ding does not work in batch mode,
emacs --batch --eval \
'(let ((ring-bell-function (lambda () (print "ding")))) (ding))'
but it could be tested with cl-letf,
(require 'ert)
(should-error
(progn (define-error 'ding "Ring my bell!")
(cl-letf (((symbol-function 'ding)
(lambda () (signal 'ding nil))))
(ding)))
:type 'ding)
(ding)