Before we start coding tests, we need to learn a couple of things about the technique behind test code, the so-called testability framework.
Since NAV 2009 Service Pack 1, Microsoft has allowed the platform to let you build test suites by means of test functions in test codeunits. When executing a test codeunit, the platform will do the following:
- Run the OnRun trigger and each test function that resides in the test codeunit, from top to bottom
- Record the result of each test function
This is what Luc van Vugt calls the first pillar of the testability framework. Our first test example will implement this.
The second pillar allows you to create so-called positive–negative, or rainy-path, tests, in which we test the circumstances that led to failure. To achieve this, we use the AL asserterror keyword, which should...