In the ideal world you have a nightly build, creating your entire solution from scratch, running all the automated tests that come with standard NAV and so on.
During business hours you basically want the same thing but a lot faster, you want to have feedback about your modifications as quickly as possible and running all the tests might be unnecessary and it’s very much time consuming.
You might have seen this sneaky little option when you add test codeunits to your suite:
Btw: the last two options only pop up if you have at least one record in table 130406 CAL Test Coverage Map.
So what do we have to do to get this to work?
Before you can take advantage of the last two options you should run all the available tests but before that make sure that the ‘Update Test Coverage Map’ setting on your test suite is set to true.
When this setting is active the CAL Test Runner will start/stop the Code Coverage tool for each test codeunit, loop table 2000000049 Code Coverage and store the unique combinations of
Test Codeunit ID, Object Type, Object ID in the CAL Test Coverage Map table.
Because of the fact that the Code Coverage table is a virtual table, all the data will be lost when you close your session, however the CAL Test Coverage Map table is stored in the database so we can retrieve tests based on modified/selected objects!
Retrieving them based on the modified flag in the object table is also a weakness because your objects will most likely come from a source control system and you’ll never store them as modified.
But there are plenty of workarounds, for example:
– write your own filter function before hooking into the GetTestCodeunitsForObjects function in codeunit CAL Test Management (unfortunately it’s local)
– use the Set-NAVApplicationObjectProperty cmdlet to (temporarily) set the modified property to true before importing your objects into the database.