We will do simple module which will write Hello world to frontend. See https://michalmachovic.github.io/php,%20magento2/2019/02/07/magento2-basic-module.html. We added Test/Unit/SampleTest.php file, you can see here assertEquals testing of getHelloWorldTxt method of Helloworld class defined in Block/Helloworld.php.
There is PHPUnit configuration file shipped with Magento 2 – {ROOT}/dev/tests/unit/phpunit.xml.dist. Create phpunit.xml file in the same location and your test location (you can comment out other tests defined there, if you dont want to test everything):