ERT is an Emacs Lisp library for regression/unit testing. It is now included in Emacs, but can still be retrieved from its old repository.

For examples of how to write tests with ERT, take a look at the manual in Info, C-h i m ert RET, or read the manual online, or look at ERT's own tests.

Lisp:ert-expectations.el translates EmacsLispExpectations syntax into ERT. You can use simple EmacsLispExpectations code in ERT environment. – rubikitch

If you want to run a single ERT test programmatically, here is the syntax. See the full thread at StackOverFlow.

    (ert-test-passed-p (ert-run-test (ert-get-test 'my-deftest-name)))
    nil  ;; test my-deftest-name failed
    t    ;; test my-deftest-name passed

See also UnitTesting