承認テスト ライブラリ のリソース

承認テスト ライブラリ (ATL) は、X++ テスト ライブラリであり、以下の利点を提供します:

  • 一貫したテスト データを作成できます。
  • テスト コードが読みやすくなります。
  • テスト データの作成に使用されているメソッドの発見可能性が向上します。
  • 前提条件の設定の複雑さを隠します。
  • パフォーマンスの高いテスト ケースをサポートします。

ATL で記述されたテストの例

// Create the data root node
var data = AtlDataRootNode::construct();

// 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(-7),
    invent.trans().spec().withStatusIssue(StatusIssue::ReservPhysical).withInventDims([warehouse]).withQty(-3)); 

概念

ATL のクラスとメソッドの構造と命名は非常に厳格です。 この厳格さにより、発見性が向上し、慣れないドメインでさえもテストを簡単に作成できるようになります。

クラスは次の概念に分類されます:

  • ナビゲーション – 慣れている階層でエンティティを検出し、データ メソッドをテストします。
  • テスト データ メソッド – これらのメソッドはテスト データの設定に使用されます。
  • エンティティ – エンティティは、ひとつの単位として認識されるデータと、それに関連する動作を表します。
  • 作成者 – 作成者により特定のテスト データを作成できます。
  • コマンド – コマンドは事業運営を実行します。
  • クエリ – クエリはエンティティを検索します。
  • 仕様 – 仕様はテストの終わりで期待されるエンティティを説明します。

コード生成

クエリと仕様は、エンティティの作成プロセスを簡素化するのに役立ちます。 詳細は 承認テスト ライブラリ コード生成ウィザード を参照してください。 コード生成 ウィザードを使用してシナリオを作成し、またそれらを更新することができます。

参考文献

何千ものテスト基盤として、Microsoft は ATL を社内で何年も使用してきました。 詳細については 承認テスト ライブラリのベスト プラクティス および 承認テスト ライブラリについてよく寄せられる質問 を参照してください。