How to Run SNMP Trap Handler Unit Tests

Hi

I’ve written a bunch of snmp trap handlers for some pretty common Cisco traps and some more niche industrial environment monitoring ones. I’ll be writign more too. They’ve been working well for several months to a year and I’d like to start submitting them as PRs to LibreNMS but doing so requires unit tests.

I’ve written some unit tests by copying those already in ~/tests/Feature/SnmpTraps and adapting them accordingly but I’ve no idea on how to run the tests to see if they work.

I’ve followed this but there’s nothing in there about traps. I’ve read this but there’s nothing in there about running the tests (and the example looks outdated compared to the ones shipping with LibreNMS).

Can anyone point me in the right direction?

I should add I have tried just running the trap test unit directly and get:

PHP Fatal error:  Uncaught Error: Class "LibreNMS\Tests\Feature\SnmpTraps\SnmpTrapTestCase" not found in /opt/librenms/tests/Feature/SnmpTraps/AxisVideoTrapsTest.php:28
Stack trace:
#0 {main}
  thrown in /opt/librenms/tests/Feature/SnmpTraps/AxisVideoTrapsTest.php on line 28

and get the same error running any other test trap units, e.g.:

php /opt/librenms/tests/Feature/SnmpTraps/ApcPduOverloadTest.php
PHP Fatal error:  Uncaught Error: Class "LibreNMS\Tests\Feature\SnmpTraps\SnmpTrapTestCase" not found in /opt/librenms/tests/Feature/SnmpTraps/ApcPduOverloadTest.php:27
Stack trace:
#0 {main}
  thrown in /opt/librenms/tests/Feature/SnmpTraps/ApcPduOverloadTest.php on line 27

To update, I found it. It was simply to run:

lnms dev:check

There was so much output I missed seeing my test output in there and started looking for command options to specify either the trap handler tests or my own handler test specifically, which you can’t do.