Acceptance test library
Functionality noted in this topic is available to targeted users as part of a preview release. The content and the functionality are subject to change. For more information about preview releases, see Service update availability.
The Acceptance test library (ATL) is an X++ test library that offers the following benefits:
- It lets you create consistent test data.
- It increases the readability of test code.
- It provides improved discoverability of the methods that are used to create test data.
- It hides the complexity of setting up prerequisites.
- It supports high performance of test cases.
Example of a test that is written in ATL
// 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));
The structure and naming of the classes and methods in ATL are quite rigid. This rigidity helps improve discoverability and also makes it easier to write tests, even in domains that you're unfamiliar with.
The classes are grouped into the following concepts:
- Navigation – Discover entities and test data methods in a familiar hierarchy.
- Test data methods – These methods are used to set up test data.
- Entities – Entities represent data and associated behavior that is perceived as a single unit.
- Creators – Creators let you create specific test data.
- Commands – Commands run business operations.
- Queries – Queries find entities.
- Specifications – Specifications describe expected entities at the end of the test.
Queries and specifications help simplify the process of creating entities. For more information, see Acceptance test library Code generation wizard. The Code generation wizard can be used to create scenarios and update them.
Microsoft has used ATL internally for several years, as the foundation for thousands of tests. For more information see, Best practices for the Acceptance test library and Acceptance test library FAQ.
Send feedback about: