본문으로 건너뛰기
cccskills
무료GitHub에 공개

running-tests

Guide for running tests in the openai-dotnet repository. Use this when asked to run, debug, or validate tests, or when writing new tests. Explains test modes (Playback, Record, Live), how to identify recorded vs non-recorded tests, environment variable configuration, and what to do when recordings are missing or stale.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구OpenAI
설치 방법 보기

포함된 파일(1)

  • SKILL.md5.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Running Tests

Overview

Tests in this repository use the Microsoft.ClientModel.TestFramework and NUnit.

Many tests rely on session recordings — pre-recorded HTTP interactions stored in tests/SessionRecords/ — so they can run without live service access. The repository defaults to Playback mode unless overridden in the environment.

Test Modes

ModeDescription
PlaybackTests run against pre-recorded session data in tests/SessionRecords/. No API key is required.
RecordTests run against the live OpenAI API and produce or update session recordings. Requires an API key.
LiveTests run against the live OpenAI API without producing or updating session recordings. Requires an API key.

The mode is controlled by the CLIENTMODEL_TEST_MODE environment variable and accepts Playback, Record, or Live.

In Playback mode, the framework may attempt to auto-record when a session recording is missing or stale. Disable that behavior by explicitly setting CLIENTMODEL_DISABLE_AUTO_RECORDING to true.

Agent Rules

As the agent, only execute tests in Playback mode.

Do not run Record or Live mode yourself. Those paths require live credentials which you do not have.

Before running tests, always set:

$env:CLIENTMODEL_TEST_MODE = "Playback"
$env:CLIENTMODEL_DISABLE_AUTO_RECORDING = "true"

If a recorded test needs new recordings or updated recordings, you must follow the instructions below to ask a human to capture them for you instead of trying to capture them yourself.

Identifying Recorded Tests vs Non-Recorded Tests

Treat these as practical indicators instead of a rigid checklist.

Strong signals that a test is a recorded test:

  • The test class inherits from OpenAIRecordedTestBase.
  • The test method uses [RecordedTest].
  • The test gets clients through GetProxiedOpenAIClient.
  • The test exercises real service behavior rather than mocked responses.

Strong signals that a test is not a recorded test:

  • The test class inherits from something other than OpenAIRecordedTestBase or has no base class.
  • The test method uses plain [Test] instead of [RecordedTest].
  • The test uses mocked transports or handcrafted responses to simulate HTTP responses, such as MockPipelineTransport, MockPipelineResponse, or GetClientOptionsWithMockResponse.
  • The test does not need to reach a live cloud service.

When Recordings Are Missing or Stale

Recordings must be captured by a human.

Request recordings from a human before considering your work complete in either of the following cases:

  1. You added a new recorded test (which implies its recording is missing because it has never been recorded before).
  2. An existing recorded test fails in Playback mode because its recording is missing or stale (for example, if the recorded test was modified and the existing recording no longer matches).

When asking for recordings, always provide:

  1. The link to the recording workflow
  2. The exact NUnit.Where expression
  3. A copy-pasteable dotnet test command

You must use this template:

Please record tests using the recording workflow: https://github.com/openai/openai-dotnet/actions/workflows/record-test.yml

Use the following NUnit.Where expression:

test == 'Namespace.TestClass.TestMethodName'

Alternatively, run the following command locally and push the recordings manually:

dotnet test ./tests/OpenAI.Tests.csproj --configuration Release --framework "net10.0" -- NUnit.Where="test == 'Namespace.TestClass.TestMethodName'"

Use NUnit.Where for recording requests even when dotnet test --filter would work locally. NUnit.Where is the contract used by the recording workflow. Prefer test == ... because it matches the exact discovered NUnit test name and avoids ambiguity. For NUnit fixture-parameterized tests such as classes constructed with bool isAsync, the discovered test names may include fixture arguments like (True) or (False).

For a single ordinary test, use:

test == 'Namespace.TestClass.TestMethodName'

If you need one exact fixture instance, use:

test == 'Namespace.TestClass(True).TestMethodName'

Example for async fixture instance of the GenerateSingleEmbedding recorded test:

test == 'OpenAI.Tests.Embeddings.EmbeddingsTests(True).GenerateSingleEmbedding'

If multiple tests need recording, combine them in a single NUnit.Where expression:

(test == 'Namespace.TestClass.TestA') or (test == 'Namespace.TestClass.TestB')

Example for both fixture instances of the GenerateSingleEmbedding recorded test:

(test == 'OpenAI.Tests.Embeddings.EmbeddingsTests(True).GenerateSingleEmbedding') or (test == 'OpenAI.Tests.Embeddings.EmbeddingsTests(False).GenerateSingleEmbedding')

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for ingesting the latest OpenAI TypeSpec specification into the openai-dotnet SDK. Use this when asked to update or ingest OpenAI API specs, copy base TypeSpec files from upstream, fix client TSP compile errors, or run code generation for new API areas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

openai/openai-dotnet2.7천2026년 10월 19일 업데이트

openai의 스킬 모두 보기

이 스킬의 문제 신고