The Unit Test module runs tests that modules include. Put them in your module's tests/ folder: each file, such as tests/strings.php, defines test_(module)_(file)(), for example test_xxFoo_strings().
function test_xxFoo_strings()
{
jrUnitTest_init_test('slug of a title');
if (xxFoo_slug('Hello World') != 'hello-world') {
jrUnitTest_exit_with_error('unexpected slug');
}
}Each jrUnitTest_init_test() starts a named check; jrUnitTest_exit_with_error() fails it. Run the tests from ACP > Modules > Developer > Unit Test > Run Unit Tests, and see which lines they ran with Coverage Browser (it needs Xdebug).
Tests run inside your real site, with its database. Run them on a development site only.
The core's own tests, in modules/jrCore/tests/, are good examples.
To test pages as a user sees them (logging in, filling in forms, clicking buttons), use a browser automation tool such as Playwright or Selenium with php-webdriver, against your development site. Log in once, save the session, and reuse it for each test. Point the tests at the forms' field names, such as user_email_or_name and user_password on the login form.