In a forum thread a user asked for a code coverage tool. Microsoft has developed the Nav 2013 Application Test Toolset, but did not deliver a version for Nav 2013 r2 or Nav 2015. It’s possible to import this Toolset in Nav 2013 r2, but … it does not work. There are some ugly error messages, when running. So i analysed the nav objects of the toolset and made the needed changes. When testing the toolset, especially the code coverage tool, i noticed, that many of the test codeunits are unnecessarily called during execution. So error after error occured. The reasons for the error messages seem partly conversion issues, version problems, changes in standard objects and bugs. 

The list of codeunits, which need changes:
130002 Code Coverage Mgt
131301 Library – ERM Unapply
134012 ERM Reminder Apply Unapply
134386 ERM Sales Documents II
134976 ERM Sales Report
134984 ERM Sales Report III
136601 Config. Templates
136606 Config. Wizard & Worksheet
137065 SCM Reservation II
137067 SCM Plan-Req. Wksht
137400 SCM Inventory – Orders
137925 Test Assembly Reservation

Because, i assume, it would be a copyright violation, i do not publish the changed objects. So i describe the needed changes.

130002 Code Coverage Mgt

This CU uses a global variable Timer with (old) subtype “Microsoft.Dynamics.Nav.Timer, Version=7.0.0.0″. Replace the subtype by “Microsoft.Dynamics.Nav.Timer, Version=7.1.0.0″, which is shipped with Nav 2013 r2.
Before you replace the subtype copy the code of the triggers Timer::Elapsed and Timer::ExceptionOccurred to an external text editor. After replacing the subtype copy the code back to the triggers.

131301 Library – ERM Unapply

Function UnapplyCustomerLedgerEntry(CustLedgerEntry : Record “Cust. Ledger Entry”):
replace
GenJnlPostLine.UnapplyVendLedgEntry(GenJournalLine,DetailedCustLedgEntry);
with
GenJnlPostLine.UnapplyCustLedgEntry(GenJournalLine,DetailedCustLedgEntry);

134012 ERM Reminder Apply Unapply

Function CreateReminder(DocumentNo : Code[20];CustomerNo : Code[20])
replace
ReminderMake.Set(Customer,CustLedgerEntry,ReminderHeader,FALSE,FALSE);
with
// function interface (parameter list) was changed between the nav versions
ReminderMake.Set(Customer,CustLedgerEntry,ReminderHeader,FALSE,FALSE,CustLedgerEntry);

134386 ERM Sales Documents II

Function VerifyNavigateEntry(ExtDocNo : Code[20])
replace
Navigate.FindByItemReference.SETVALUE(ExtDocNo);
with
Navigate.ExtDocNo.SETVALUE(ExtDocNo);

134976 ERM Sales Report

Function SaveStatementReport(CustomerNo : Code[20];PostingDate : Date;PrintOverdueEntries : Boolean;PrintReversedEntries : Boolean;PrintUnappliedEntries : Boolean;IncludeAgingBand : Boolean;PeriodLength : DateFormula)
replace
Statement.InitializeRequest(
PrintOverdueEntries,TRUE,FALSE,PrintReversedEntries,PrintUnappliedEntries,IncludeAgingBand,
FORMAT(PeriodLength),DateChoice::”Posting Date”,FALSE);
with
Statement.InitializeRequest(
PrintOverdueEntries,TRUE,FALSE,PrintReversedEntries,PrintUnappliedEntries,IncludeAgingBand,
FORMAT(PeriodLength),DateChoice::”Posting Date”,FALSE,
DMY2DATE(1,1,DATE2DMY(PostingDate,3)),DMY2DATE(31,12,DATE2DMY(CALCDATE(‘<1Y>’,PostingDate),3)));

134984 ERM Sales Report III

Function [Test] CustomerStatementReportWithGenLines()
replace
Statement.InitializeRequest(
FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,'<‘ + FORMAT(RandomNumberGenerator.RandInt(5)) +
‘M>’,DateChoice::”Due Date”,TRUE);
with
Statement.InitializeRequest(
FALSE,FALSE,TRUE,FALSE,FALSE,FALSE,'<‘ + FORMAT(RandomNumberGenerator.RandInt(5)) +
‘M>’,DateChoice::”Due Date”,TRUE,
WORKDATE,WORKDATE);

Function SaveCustomerBalanceToDate(No : Code[20];AmountInLCY : Boolean;UnappliedEntries : Boolean)
replace
CustomerBalanceToDate.InitializeRequest(AmountInLCY,FALSE,UnappliedEntries);
with
CustomerBalanceToDate.InitializeRequest(AmountInLCY,FALSE,UnappliedEntries,WORKDATE);

136601 Config. Templates

Function [Test] ValidateFieldWithTrigger_SkipValidationFalse_TriggerError()
replace
ASSERTERROR ConfigValidateManagement.ValidateFieldValue(RecRef,FieldRef,FORMAT(Item.”Costing Method”::Standard),FALSE);
with
ASSERTERROR ConfigValidateManagement.ValidateFieldValue(RecRef,FieldRef,FORMAT(Item.”Costing Method”::Standard),FALSE,0);

Function [Test] ValidateFieldWithTrigger_SkipValidationTrue_NoErrors()
replace
ConfigValidateManagement.ValidateFieldValue(RecRef,FieldRef,FORMAT(Item.”Costing Method”::Standard),TRUE);
with
ConfigValidateManagement.ValidateFieldValue(RecRef,FieldRef,FORMAT(Item.”Costing Method”::Standard),TRUE,0);

136606 Config. Wizard & Worksheet

Function [Test] VerifyImportPackage()
replace
ConfigSetup.ImportPackage;
with
ConfigSetup.ImportPackage(ConfigSetup.”Package File Name”);

137065 SCM Reservation II

Function [Test] ReleasedProdOrderComponentsPageWithLocation()
replace
ReleasedProductionOrder.Components.INVOKE;
with
ReleasedProductionOrder.ProdOrderLines.Action1901991404.INVOKE;

Links:

cheers

 


Filed under: nav 2013, nav 2013 r2 Tagged: code coverage, nav 2013 r2, testing