Tagged: Test

NAV 2009 SP1 – Testing Codeunits – Part 2

In the earlier article, we where using the ConfirmHandler – but confirm is not everything a function can contain. So why not add the handling of Message Boxes ;-)

First, let us a add simple test message function to the previous created “doTest” codeunit. The function could look this:

 cside |  copy code |? 
PROCEDURE TestMessage@1112800001(useWrong@1112800000 : Boolean) : Boolean;
BEGIN
  IF useWrong THEN
    MESSAGE('Wrong Message')
  ELSE
    MESSAGE('Test Ok');
  EXIT(TRUE);
END;

Read more »

NAV 2009 SP1 – Testing Codeunits

One of the new features in NAV 2009 SP1 is C/AL Testability.

Let try using the new feature to test a simple codeunit – let us call the codeunit doTest. The codeunit will only contain a simple function, that includes a confirm and will look like this:

 cside |  copy code |? 
PROCEDURE TestConfirm@1112800000(useConfirm@1112800000 : Boolean) out : Boolean;
BEGIN
    IF useConfirm THEN
        IF CONFIRM('Do you confirm?',TRUE) THEN
          EXIT(TRUE)
        ELSE
          ERROR('No confirmation!');
    EXIT(FALSE);
END;

Read more »