Modifica

Condividi tramite


Specification classes

Note

Community interest groups have now moved from Yammer to Microsoft Viva Engage. To join a Viva Engage community and take part in the latest discussions, fill out the Request access to Finance and Operations Viva Engage Community form and choose the community you want to join.

A specification class provides fluent application programming interfaces (APIs) that you use to define the set of criteria that an entity should meet. Use specifications in validation scenarios, usually together with query classes.

An advantage of specification classes is that the validation code becomes very concise and expressive. You can perform multiple validations in a single line of code.

Naming convention

AtlSpec<ModuleName><#EntityName>

In this naming convention:

  • <ModuleName> is optional. Use the names of the modules on the main menu. However, use a short version or an abbreviation to keep the test code brief.
  • <#EntityName> represents the name of the entity that you use throughout the Acceptance test library (ATL).

Examples

AtlSpecWHSLoadLine

AtlSpecWHSWorkLine

Implementation

Specification classes should provide fluent setter methods to specify various criteria of the specification.

Example

The following code verifies that the work contains six lines that meet the specified criteria. For example, the first line has 1 as the line number, Pick as the work type, 1 as the quantity, Closed as the status, and bulk as the location.

work.lines().assertExpectedLines(
    workLines.spec().withLineNum(1).withWorkType(WHSWorkType::Pick).setQuantity(1)
        .setStatus(WHSWorkStatus::Closed).setLocation(locations.bulk()),
    workLines.spec().withLineNum(2).withWorkType(WHSWorkType::Pick).setQuantity(1)
        .setStatus(WHSWorkStatus::Closed).setLocation(locations.floor()),
    workLines.spec().withLineNum(3).withWorkType(WHSWorkType::Put)
        .setQuantity(2).setStatus(WHSWorkStatus::Closed).setLocation(locations.stage()),
    workLines.spec().withLineNum(4).withWorkType(WHSWorkType::Pick).setQuantity(2)
        .setStatus(WHSWorkStatus::Cancelled).setLocation(locations.stage()),
    workLines.spec().withLineNum(5).withWorkType(WHSWorkType::Put).setQuantity(2).setStatus(WHSWorkStatus::Cancelled)
);