programing

테스트 탐색기에서 실행되지 않는 테스트

nasanasas 2021. 1. 9. 10:07
반응형

테스트 탐색기에서 실행되지 않는 테스트


현재 32 개의 Unittest가있는 솔루션을 개발 중입니다. 나는 resharper 테스트 러너와 함께 일하고 있습니다-잘 작동합니다. 모든 테스트가 실행 중이고 모든 테스트가 올바른 테스트 결과를 보여줍니다. 이제 동료가 Visual Studio 테스트 탐색기를 사용하여 자신의 컴퓨터에서 테스트가 실행되고 있지 않다고 말했습니다. 그들은 내 컴퓨터에서 작동하지 않으므로 일부 로컬 누락 파일 또는 무언가를 제외 할 수 있습니다.

테스트 탐색기에 모든 단위 테스트가 표시되지만 "모두 실행"을 클릭하면 모든 테스트가 회색으로 표시되고 테스트 실행 결과가 표시되지 않습니다.

여기에 이미지 설명 입력

  • 모든 시험 수업은 공개됩니다
  • 모든 테스트 클래스에는 [TestClass]속성이 선언되어 있습니다.
  • 모든 테스트 방법은 [TestMethod]속성을 사용 합니다.
  • 생산성 코드와 테스트 프로젝트는 모두 .NET 3.5를 대상으로합니다.
  • 나는 이미 정리 빌드에 내 솔루션을 시도, 및 / 또는 모두 삭제 한 obj, bin, DebugRelease폴더를

그러한 행동을 유발할 수있는 힌트가 있으면 감사하겠습니다.


프로젝트가 모두 AnyCpu가 아닌 경우 다음 두 설정이 일치하는지 확인할 수도 있습니다.

  1. [테스트 프로젝트 오른쪽 클릭]-> 속성-> 빌드-> 플랫폼 대상-예 : x64

  2. [주 메뉴]-> 테스트-> 테스트 설정-> 기본 프로세서 아키텍처-> X64

이것이 내 테스트 프로젝트와 일치하지 않으면 조용히 실행에 실패한다는 것을 알았습니다.


VS 2017에서도 같은 문제가 발생했습니다. 제 경우에는 VS를 다시 시작하여 해결했습니다.


MSTest가 아닌 NUnit을 사용하는 경우 Visual Studio 2012/2013 용 NUnit 테스트 어댑터 확장 이 필요합니다 .


void 대신 Task를 반환하도록 비동기 테스트 메서드를 변경해야했습니다.

그런 다음 테스트가 활성화되고 테스트 탐색기에서 실행할 수 있습니다.


테스트가 작성된 프레임 워크 (예 : nunit, xunit, VS 테스트 등)를 확인하고 올바른 테스트 어댑터 / 러너 확장이 설치되어 있는지 확인합니다.

저에게는 NUnit 3 테스트 어댑터가 없었고 nunit.framework 종속성 버전을보고 필요한 버전 번호를 확인했습니다.


제 경우에는 솔루션의 한 테스트 프로젝트에 MSTest.TestFramework 및 MSTest.TestAdapter 너겟 패키지가 설치되었지만 다른 테스트 프로젝트는 설치되지 않았기 때문입니다. 이러한 패키지는 솔루션의 한 프로젝트에 설치 될 때까지 테스트를 실행할 필요가 없었습니다.

이 문제는 패키지가 누락 된 테스트 프로젝트에 해당 패키지를 설치하여 해결되었습니다.


Clean-Rebuild 솔루션이 저에게 효과적이었습니다.


나는 같은 증상이 있었다.

도구-확장 및 업데이트를 통해 적절한 Visual Studio 확장이 설치되어 있는지 확인하십시오. 제 경우에는 온라인 옵션에서 XUnit과 Specflow를 설치해야했습니다.

그런 다음 솔루션을 청소하고 다시 빌드하십시오.

그래도 도움이되지 않으면 임시 디렉토리를 지우십시오 (시작 메뉴 검색에서 % temp %를 검색하고 Temp의 모든 내용을 삭제하십시오).

그리고 마침내 Resharper를 제거하여 마침내 내 문제를 해결하십시오.


나를 위해 수정 한 것은 MS.Test nuget 패키지를 업그레이드하는 것입니다.


나를 위해 VS2017을 다시 시작해도 작동하지 않았습니다. sln을 정리 한 다음 해당 파일 만 실행하고 실행하지 않는 테스트 파일을 찾았습니다. 그 후 나는 모두 실행했고 다시 정상적으로 작동했습니다.


여기에 테스트 프로젝트가 빌드되도록 표시되지 않았습니다.

빌드-> 구성 관리자 ...-> 테스트 프로젝트의 빌드 확인


이런 종류의 오류로 여기에 왔기 때문에 문제 / 해결 방법을 게시합니다.

조짐:

  • 모든 테스트가 실행되는 것은 아니지만 프로젝트별로 의존하지 않고 일부만 실행되었습니다.
  • 처형 된 사람은 모두 녹색이었습니다.
  • 기술 스택 : dotnet core / XUnit / FluentAssertions
  • 변경된 경우 모든 테스트가 감지되고 업데이트되었습니다.
  • "실행되지 않은 테스트"를 여러 번 선택하거나 실행하여 실행할 수 있습니다.

문제:

다른 스레드 내에서 예외를 발생시키는 코드에 오류가 있습니다. 모든 테스트 어설 션이 통과되었지만 테스트 실행이 취소되었습니다. "테스트 출력"(NullException)에서 오류를 볼 수 있습니다.


저에게 해결책은 Resharper Unit Testing 설정 "기본 플랫폼 아키텍처"를 "x64"로 변경하는 것이 었습니다.

여기에 이미지 설명 입력


For me (not quite a solution) it was deselecting the .testsettings file in the Menu [Test]->[Test Settings]->[{current File}] to uncheck the currently used file.

In my case it starts so.

<TestSettings name="Local (with code coverage)" id="e81d13d9-42d0-41b9-8f31-f719648d8d2d" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Deployment>
    <DeploymentItem filename="ConfigurationImportExportTest\Configurations\" />
    <DeploymentItem filename="output\Debug\" />
  </Deployment>
  <Execution>

Apparently the DeploymentItem interferes.

because this was in the Output tab:

Warning: Test Run deployment issue: The assembly or module 'Microsoft.SqlServer.Management.SqlParser' directly or indirectly referenced by deployment item 'output\Debug\' specified by the test settings was not found.
.... more of the same

It does not tell me lots.
Seems like it has to do with the way that all projects put their compilation products in a common \output\Debug folder

however that seems not to hinder it. It puts out another warning mentioning things like

A testsettings or runsettings file with `ForcedLegacyMode = TRUE or VSMDI files are not supported by MSTest-V2.

That seems to stop it.


Check in your project file for references to NUnit of different versions:

In my case, I had installed version 3.11.0 of both NUnit and NUnit3TestAdapter, but there were old references to version 2.6.4, in the project file, that weren't removed with the new installation.

  • Solution (Recomended to fix references issues, see docs):

    Reinstall NUnit and NUnit3TestAdapter, this fixed the references in my project.
PM> Update-Package NUnit -reinstall
...
PM> Update-Package NUnit3TestAdapter -reinstall
  • Solution 2 (In case of reinstalling didn't fix the references):

    Uninstall and install NUnit and NUnit3TestAdapter.
PM> Uninstall-Package NUnit
...
PM> Uninstall-Package NUnit3TestAdapter
...
PM> Install-Package NUnit
...
PM> Install-Package NUnit3TestAdapter

For me this was caused by a VS extension for measuring code coverage. It could not reference a particular assembly, and therefore would not run any of the tests. Tests would run fine from the command line using:

dotnet test

To solve this issue, you can opt to have ALL dependencies copied to your Test project debug folder. This ensures that any assemblies can be resolved, as "unused" assemblies are not removed. You can add the following to your Test projects .csprog file:

<PropertyGroup>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>

I had different version of NUnit (3.11.0) and NunitTestAdapter (3.12.0) nuget packages. When I updated NUnit to 3.12.0, Visual Studio ran tests.


In my case it worked to update the MSTest nuget packages. Could reproduce this problem even on blank MSTest project and updating the packages worked.


For me having a property called TestContext in a base class was causing this behavior. For example:

[TestClass]
public abstract class TestClassBase
{
    protected object TestContext { get; private set; }
}

[TestClass]
public class TestClass : TestClassBase
{
    // This method not found
    [TestMethod]
    public void TestCase() {}
}

Try removing the [Ignore] attribute from above the test method.

참조 URL : https://stackoverflow.com/questions/23363073/tests-not-running-in-test-explorer

반응형