Skip to main content

create-recorded-test

Generate a new recorded integration test

소스 정보

저장소
Azure/azure-sdk-for-rust
최근 소스 활동
2026년 6월 11일 22:49
감지된 SKILL.md 언어
영어
스타
885
포크
375

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
create-recorded-test
description
Generate a new recorded integration test
disable-model-invocation
true
# Generate a new recorded integration test You will generate one or more recorded integration tests under the `sdk/{service-directory}/{crate-name}/tests` directory in `${input:testFile:test_file}.rs` where: - `{repo-root}` is the root directory containing `Cargo.toml`. - `{service-directory}` is the directory name under [sdk](../../../sdk) for the current ${file} e.g., `keyvault`. - `{crate-name}` is the crate directory name under `sdk/{service-directory}` for the current ${file} e.g., `azure_security_keyvault_secrets`. ## Set up These instructions only need to be done once. If changes described are already present, do not make the changes again. - Recorded tests must always be integration tests under the `sdk/{service-directory}/{crate-name}/tests` directory. Do not add recorded tests to `src/`, `examples/`, or `README.md`. - If PowerShell is not installed, stop and ask the user to install it first using [PowerShell installation instructions](https://learn.microsoft.com/powershell/scripting/install/installing-powershell). - Provision test resources using the full script path: ```bash {repo-root}/eng/common/TestResources/New-TestResources.ps1 -ServiceDirectory {service-directory} ``` - To run recorded tests, rely on the existing test infrastructure. Test Proxy is acquired automatically for test runs when needed, but not for `test-proxy push -a sdk/{service-directory}/assets.json`. - For manual Test Proxy usage or asset publishing, see [CONTRIBUTING.md](../../../CONTRIBUTING.md) and the [Test Proxy documentation](https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md). ## Adding a new recorded test For each new recorded test: - In `sdk/{service-directory}/{crate-name}/tests/${input:testFile}.rs`, add or update async integration tests attributed with `#[recorded::test]`. - Use the signature `async fn ${input:testName}(ctx: TestContext) -> Result<()>`. - Start each test with: - `let recording = ctx.recording();` - `let mut options = {Client}Options::default();` - `recording.instrument(&mut options.client_options);` - Construct clients with `recording.var("{ENV_VAR}", None).as_str()`, `recording.credential()`, and `Some(options)`. - Use [sdk/keyvault/azure_security_keyvault_secrets/tests/secret_client.rs](../../../sdk/keyvault/azure_security_keyvault_secrets/tests/secret_client.rs) as the example for function signatures, `TestContext`, and required `ClientOptions` instrumentation. - Generate one test per client method or scenario the user wants to cover. If multiple methods share setup and belong together, keep them in the same integration test file as separate `#[recorded::test]` functions. - Prefer asserting on returned models or observable state instead of only checking success. - Reuse existing crate patterns for imports, helper types, resource naming, and environment variables. ## Recording and playback - Record or update sessions against live resources: ```bash AZURE_TEST_MODE=record cargo test -p {crate-name} --test ${input:testFile} ``` - Run playback to make sure tests were properly recorded: ```bash cargo test -p {crate-name} --test ${input:testFile} ``` - After recording and playback succeeds, publish updated recordings only if `test-proxy` is already installed and available: ```bash test-proxy push -a sdk/{service-directory}/assets.json ``` ## Tear down - Remove provisioned test resources using the full script path when they are no longer needed: ```bash {repo-root}/eng/common/TestResources/Remove-TestResources.ps1 -ServiceDirectory {service-directory} ```
GitHub에서 보기