Stubbing out functions or using so-called mocks can make it easier to write tests. See https://en.wikipedia.org/wiki/Mock_object for an explanation of the corresponding concepts in object-oriented languages.
ERT does not have built-in support for mocks or stubs. The package
el-mock
(see https://www.emacswiki.org/emacs/el-mock.el)
offers mocks for Emacs Lisp and can be used in conjunction with ERT.