다음을 통해 공유


테스트 실행 및 디버그

Microsoft.Testing.Platform 테스트 프로젝트는 직접 실행(또는 디버그)할 수 있는 실행 파일로 빌드됩니다. 콘솔 또는 명령을 실행하는 추가 테스트는 없습니다. 대부분의 실행 파일에 일반적인 오류가 있는 경우 앱은 0이 아닌 종료 코드로 종료됩니다. 알려진 종료 코드에 대한 자세한 내용은 microsoft.Testing.Platform 종료 코드 참조하세요.

팁 (조언)

명령줄 옵션을 사용하여 특정 --ignore-exit-code 무시할 수 있습니다.

TestingPlatformCommandLineArguments MSBuild 속성을 사용하여 project 파일의 특정 테스트 project 적용되는 명령줄 옵션을 설정할 수도 있습니다. 한 가지 일반적인 사용 사례는 모든 테스트가 무시된 테스트 프로젝트에 대한 것이며, 일반적으로 종료 코드 8(테스트 세션이 0개 테스트를 실행)으로 종료됩니다. 이 시나리오에서는 project 파일의 PropertyGroup 아래에 다음을 추가할 수 있습니다.

<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --ignore-exit-code 8</TestingPlatformCommandLineArguments>

중요합니다

기본적으로 Microsoft.Testing.Platform는 원격 측정을 수집합니다. 옵트아웃에 대한 자세한 내용 및 옵션은 Microsoft.Testing.Platform 원격 분석을 참조하세요.

dotnet publish 사용하여 테스트 project 게시하고 앱을 직접 실행하는 것도 테스트를 실행하는 또 다른 방법입니다. 예를 들어 ./Contoso.MyTests.exe실행합니다. 일부 시나리오에서는 dotnet build 사용하여 실행 파일을 생성하는 것도 가능하지만, 네이티브 AOT 같은 에지 사례를 고려할 수 있습니다.

dotnet run 사용

dotnet run 명령을 사용하여 테스트 project 빌드하고 실행할 수 있습니다. 이는 테스트를 실행하는 가장 쉬운 방법이지만, 때로는 가장 느립니다. dotnet run 사용하면 필요할 때 테스트 project 다시 작성되므로 로컬에서 테스트를 편집하고 실행할 때 실용적입니다. dotnet run는 현재 폴더에서 프로젝트를 자동으로 찾습니다.

dotnet run --project Contoso.MyTests

dotnet run대한 자세한 내용은 dotnet run참조하세요.

dotnet exec 사용

dotnet exec 또는 dotnet 명령은 이미 빌드된 테스트 project 실행하거나 실행하는 데 사용되며, 이는 애플리케이션을 직접 실행하는 대신 사용됩니다. dotnet exec 빌드된 테스트 project dll에 대한 경로가 필요합니다.

dotnet exec Contoso.MyTests.dll

또는

dotnet Contoso.MyTests.dll

비고

테스트 project 실행 파일(*.exe)에 대한 경로를 제공하면 오류가 발생합니다.

Error:
  An assembly specified in the application dependencies manifest
  (Contoso.MyTests.deps.json) has already been found but with a different
  file extension:
    package: 'Contoso.MyTests', version: '1.0.0'
    path: 'Contoso.MyTests.dll'
    previously found assembly: 'S:\t\Contoso.MyTests\bin\Debug\net10.0\Contoso.MyTests.exe'

dotnet exec대한 자세한 내용은 dotnet exec참조하세요.

dotnet test 사용

Microsoft.Testing.Platform 새 실행 시나리오를 사용하도록 설정하면서 이전과 같이 테스트를 실행할 수 있도록 vstest.console.exedotnet test 호환성 계층을 제공합니다.

dotnet test Contoso.MyTests.dll

참고하십시오