Test-Driven Development in NAV – By Example

Our example is a simple requirement:

To prevent a user posting purchase invoices headlong he has to enter manually the total amount of the invoice lines in a field on the invoice header and only when header amount and lines total match can the document be posted.

This feature might ring a bell for those of you working with NAV BE and NL as it’s part of the standard NAV BE/NL application. However, for brevity sake, we will not take into account all the details of the BE/NL requirements.

So let’s make up our initial version of the Test List based on the above requirements: 

#

Description

1

Create PI (purchase invoice) with 1 line and check that total line amount is calculated right

2

Create PI with multiple (2) lines and check that total line amount is calculated right

3

Create PI with multiple lines and check that doc. amount verification succeeds

4

Create PI with multiple lines and check that doc. amount verification fails

Note that, while moving forward, the list might grow as we might stumble across some additional issues, but for now it seems a sufficient list, so let’s go …

… shortly after the following.

To be able to make use of the NAV testability features in it’s full extend we need to:

  1. ‘turn’ them on, and
  2. import the various test libraries provided by MS

Turn on Testability Features

  1. Open NAV 2009 classic client
  2. Select Tools > Options …
  3. Set the Show C/AL Testability properties value to Yes

Import Test Libraries

Get the Application Test Toolset for Microsoft Dynamics NAV 2009 SP1 here and import the .fob.

Finally we are set and can go. [au]

Notes

  • NAV testability features have been introduced in NAV 2009 SP1 so you will need to use NAV 2009 SP1 or higher.
  • Update 20190407 ever since NAV 2013 the testability featuresare turned on; as such the Show C/AL Testability properties option dos not exist anymore

TDD Series Index

  1. Test-Driven Development in NAV – Intro
  2. Test-Driven Development in NAV – Intro 2
  3. Test-Driven Development in NAV – By Example
  4. Test-Driven Development in NAV – Test #1
  5. TDD in NAV – Triangulation
  6. TDD in NAV – Test #2
  7. TDD in NAV – Test #3
  8. TDD in NAV – Test #4
  9. TDD in NAV – ASSERTERROR or IsFalse

 

One Comment

  1. Note that on NAV 2013 you will not find the "Show C/AL Testability properties" option. You could say it is turned on by default.

Leave a Reply

Your email address will not be published. Required fields are marked *