Skip to content

Cadl Scenario Tests

Timothee Guerin edited this page Jun 14, 2022 · 2 revisions

NOTE: This has no implementation yet. This is just a design idea

Folder structure

cadl-scenarios
  http
    vanilla: Pure http tests, this should only involve `@cadl-lang/rest` library 
    azure: Describe Functionality added by `@azure-tools/cadl-azure-core`
    arm: Describe Functionality added by `@azure-tools/cadl-azure-core`

Defining scenario

The goal of the testserver is to define scenarios that needs to be supported in client generators. This means to have a meaningful coverage we need scenarios to:

  • have a specific behavior that is meant to be tested
    • ❌ DO NOT use the same scenario for testing multiple things.
  • have a meaningful name that can be used in a compatibility table to see what a given generator support(e.g. get_string)
  • a description of what the scenario is validating(e.g. "Support passing a simple string as JSON")
  • have a good description on what the client is expecting to generate/receive/send(e.g Validate that this operation returns a JSON string that match "abc")
    • ✅ DO describe how to validate that this scenario is working from the client point of view
import "@azure-tools/cadl-scenario-lib";

@category("vanilla")
@route("/strings")
namespace StringScenarios;

@scenarioName("get_string")
@doc("Support passing a simple string as JSON")
@scenarioDoc("In this scenario the Client should expect a string matching 'abc' to be returned.")
@get @route("/simple") op returnString(): string;

Decorators that should be provided in this test library @azure-tools/cadl-scenario-lib:

  • @scenarioName: Specify the name of the scenario that will show up in the compatibility table.
  • @scenarioDoc: Specify how to implement this scenario. Differ from @doc which describe the scenario to the end user.
  • @category: Specify which category this scenario file(or operation belong to) should be consistent with the folder structure.

Compatibility table

With all this information, a detailed compatiblity table should be able to be produced by compiling each one of the scenarios and extracting the cases. Providing something like

Scenario CSharp Python Go Java TS/JS
Vanilla
get_string
put_string
Azure
pageable_nextLink
pageable_continuationToken
Clone this wiki locally