@autorest/testmodeler

中文文档
2.6.4-ci.254802bfc.0发布于 2025/06/26MITTypeScriptCommonJS近 30 天下载 6952

Autorest extension for testmodeler

原始使用文档
文档目录20 节
  1. Packages
  2. Contributing
  3. Contributor License Agreement Requirements
  4. Code of Conduct
  5. How to Generate Test Model
  6. Contribution
  7. Configurations
  8. --debug
  9. --testmodeler.mock.send-example-id
  10. --testmodeler.mock.verify-response
  11. --testmodeler.mock.disabled-examples
  12. --testmodeler.scenario.variable-defaults.location
  13. --testmodeler.scenario.codemodel-restcall-only
  14. --testmodeler.use-example-model
  15. --testmodeler.add-armtemplate-payload-string
  16. --testmodeler.api-scenario-loader-option
  17. --test-resources
  18. --testmodeler.export-explicit-type
  19. --testmodeler.explicit-types
  20. Autorest Pipeline Configurations

AutoRest SDK Test Generation Tools


Packages

NameChangelogLatest
@autorest/testmodelerChangelog
@autorest/gotestChangelog

Contributing

For instructions on cloning/building/etc, see Development

Contributor License Agreement Requirements

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Autorest Extension for Test Modeler

Generate *.md config files in Azure REST API specification:

https://github.com/Azure/azure-rest-api-specs

How to Generate Test Model

autorest --version=3.7.3 --use=<test model extension> --output-folder=<RP package path> --testmodeler.export-codemodel --clear-output-folder=false --debug <RP config md file path>

Contribution

The testmodeler use rush managing the projects. So if there is changes on package.json, remember to execute rush update updated.

> rush update

Configurations

Below are options can be used for autorest.testmodeler

--debug

Generate modeler files in [output-foler]/__debuger for debug purpose.

--testmodeler.mock.send-example-id

In generated mock test, send swagger example-id to mock service host in each request. This implicitly ask the mock service host to verify request body by swagger example content. Default true.

--testmodeler.mock.verify-response

In generated mock test, response value will be verified with the example files. Default true.

--testmodeler.mock.disabled-examples

This is an array parameter can be assigned in autorest readme file. For instance, examples Extensions_Get and Extensions_Delete will not be used in mock test generation with below configuration.

testmodeler:
    mock:
        disabled-examples:
            - Extensions_Get
            - Extensions_Delete

--testmodeler.scenario.variable-defaults.location

Set location used in scenario test, for instance:

testmodeler:
    scenario:
        variable-defaults:
            location: eastus

--testmodeler.scenario.codemodel-restcall-only

If there is no 'test-resources' defined in readme file and the readme is located in local file system, testmodeler will search all available api-scenario and try to load them as test scenario. In this context, option codemodel-restcall-only defined whether testmodeler abandon api-scenarios who contains restcall steps that can't be linked to an operation in codemodel.

The default value of this option is true.

--testmodeler.use-example-model

This option switch whether ExampleModel in generated in test model. While default to be true, it can be disabled like below:

testmodeler:
    use-example-model: false

--testmodeler.add-armtemplate-payload-string

This option switch whether StepArmTemplateModel.armTemplatePayloadString is added into testmodeler. While default to be false, it can be enabled like below:

testmodeler:
    add-armtemplate-payload-string: true

--testmodeler.api-scenario-loader-option

The api-scenarios are loaded from the autorest input-files by default. This option provide a gate to load api-scenario from other remote/branch/commit. This option are passed through directly to oav scenario loader, refer to https://github.com/Azure/oav/blob/develop/lib/apiScenario/apiScenarioLoader.ts#L60 for more detail of it. A sample for this option:

testmodeler:
    api-scenario-loader-option:
        fileRoot: https://github.com/Azure/azure-rest-api-specs/blob/eb829ed4739fccb03dd2327b7762392e74c80ae4/specification/appplatform/resource-manager
        swaggerFilePaths:
          - 'Microsoft.AppPlatform/preview/2020-11-01-preview/appplatform.json'

--test-resources

The list of api-scenarios want to get loaded into testmodeler. Below is a sample:

test-resources:
    - test: Microsoft.AppPlatform/preview/2020-11-01-preview/scenarios/Spring.yaml

--testmodeler.export-explicit-type

Whether to export codemodel with tags on primitive types, default as false. Demonstrate on the output values:

// with primitive types:
isDataAction: !!bool false
count: !!int 64


// with no types:
isDataAction: false
count: 64

--testmodeler.explicit-types

A list for types need to explicitly tagged when export-explicit-type is true. The default explicitTypes are ['bool', 'int', 'float', 'timestamp']. Test generators can change it like below:

testmodeler:
    explicit-types:
        - bool
        - int
        - float

Autorest Pipeline Configurations

clear-output-folder: false

try-require:
    - ./readme.test.md
    - ./readme.testmodeler.md

version: 3.9.7

use-extension:
  "@autorest/modelerfour" : "4.25.0"

pipeline:
    test-modeler:
        input: modelerfour/identity
        output-artifact: source-file-test-modeler
    testmodeler/emitter:
        input: test-modeler
        scope: scope-testmodeler/emitter

scope-testmodeler/emitter:
    input-artifact:
        - source-file-test-modeler
    output-uri-expr: $key
    
testmodeler:
    split-parents-value: true
testmodeler:
    export-codemodel: true

版本与发布记录

@autorest/testmodeler 共发布 29 个版本,首次发布于 2021/10/27;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.6.4-ci.254802bfc.0latest2025/06/261.4 年前
2.6.4-ci.e5cceacc3.02025/05/271.4 年前
2.6.3-ci.9c24a33e6.02024/10/032 年前
2.6.3-ci.4104d25f8.02024/10/022 年前
2.6.22024/05/142 年前
2.6.12023/08/093 年前

关于 @autorest/testmodeler 的常见问题

@autorest/testmodeler 是什么?

Autorest extension for testmodeler

如何安装 @autorest/testmodeler?

在项目目录运行 npm install @autorest/testmodeler,或使用 pnpm add / yarn add / bun add。

@autorest/testmodeler 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@autorest/testmodeler 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@autorest/testmodeler 可以商用吗?

@autorest/testmodeler 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@autorest/testmodeler 的下载量有多少?

根据 npm 官方下载统计,@autorest/testmodeler 在 2026/10/07 – 2026/11/05 这 30 天内被下载 6,952 次,日均约 232 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@autorest/testmodeler 还在维护吗?

最新版本 2.6.4-ci.254802bfc.0 发布于 2025/06/26(1.4 年前);至今共发布 29 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/10/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。