Skip to main content

Notifications

Announcements

Dynamics 365 Community / Gallery / mfp's two cents / Acceptance Test Library - t...

Acceptance Test Library - the introduction

Michael Fruergaard Pontoppidan Profile Picture Posted by Michael Fruergaard ... 1,616

The day is finally here. The Acceptance Test Library is made publicly available with 10.0.2. 

So what is it?  It is nothing short of the best productivity feature you'll get this decade as an X++ engineer.

More concretely it is a library of around 5000 classes that makes it really simple to author quality X++ tests. These are the exact same classes that Microsoft uses internally for our testing. It is so powerful, that I often find myself writing a test to repro a bug, instead of going through the UI.  The test is repeatable, debuggable and prevents regressions, whereas manual navigation of the UI is time wasted.

The ATL framework is designed for Acceptance Test Driven Development, a powerful idea where acceptance tests are defined and implemented before the production coding begins. Making the tests pass become the goal of the sprint.

You can now write a test like this:

// Get a reference to a well-known warehouse 
var warehouse = data.invent().warehouses().default();
 
// Create a new item with the "default" setup using the item creator class. Adjust the default warehouse before saving the item.
var item = items.defaultBuilder().setDefaultWarehouse(warehouse).create();

// Add on-hand (information about availability of the item in the warehouse) by using the on-hand adjustment command.
onHand.adjust().forItem(item).forInventDims([warehouse]).setQty(100).execute();

// Create a sales order with one line using the sales order entity
var salesOrder = data.sales().salesOrders().createDefault();
var salesLine = salesOrder.addLine().setItem(item).setQuantity(10).save();

// Reserve 3 units of the item using the reserve() command that is exposed directly on the sales line entity
salesLine.reserve().setQty(3).execute();

// Verify inventory transactions that are associated with the sales line using the inventoryTransactions query and specifications
salesLine.inventoryTransactions().assertExpectedLines(
    invent.trans().spec().withStatusIssue(StatusIssue::OnOrder).withInventDims([warehouse]).withQty(-3),
    invent.trans().spec().withStatusIssue(StatusIssue::ReservPhysical).withInventDims([warehouse]).withQty(-7)); 

Notice how precise it is. One line to add on-hand for an item, one line to create a sales order, etc.   That is because the API is fluent, a pattern we are not using much in X++ - but which is used throughout ATL.

This preciseness also invites for specification as example, where instead of writing requirement specification documentation, you write examples. If you write these examples using ATL, then you can run the examples as tests, and if they pass you know the system behaves according to specification. No more stale documentation or manual test.

Embrace ATL - you will not regret it.

Getting this ready for 10.0.2 was a substantial endeavor, and a few piece didn't make it into this MU, but will make it into the next one(s). This includes sample tests and the code generation wizard. Stay tuned for updates.

Learn more here:

https://docs.microsoft.com/en-gb/dynamics365/unified-operations/dev-itpro/perf-test/acceptance-test-library

THIS POST IS PROVIDED AS-IS; AND CONFERS NO RIGHTS.

Categories:

Comments

*This post is locked for comments

  • Community Member Profile Picture Community Member Microsoft Employee
    Posted at

    Hello,

    I have just created a 10.0.2 development VM, but I am not sure of the steps to follow in order to get started with ATL. Where is the library? How do I reference it? Could not find articles on the net to guide me.

  • syed baber Profile Picture syed baber 11,625
    Posted at

    Is Microsoft going to ship the standard test classes as well that are used internally for unit testing different scenarios ?

  • Florian Hopfner Profile Picture Florian Hopfner 2,440
    Posted at

    This is very good news. Seems we can now stop development of our own version of this.