IT

테스트 어댑터가 설치된 테스트 탐색기에 NUnit 장치 테스트가 표시되지 않음

lottoking 2020. 6. 23. 07:06
반응형

테스트 어댑터가 설치된 테스트 탐색기에 NUnit 장치 테스트가 표시되지 않음


VS2012 + 2013 용 NUnit 테스트 어댑터를 설치했습니다. 처음 설치할 때 어댑터 테스트가 표시되었지만 오늘 어떤 이유로 표시가 중지되었습니다. 빌드, 재 구축, 청소, 재시작 후 테스트 탐색기에 아무것도 나타나지 않습니다. 왜 이런 일이 일어날까요? VS2013 Ultimate를 사용하고 있습니다.


테스트 프로젝트가 64 비트 플랫폼을 대상으로 설정하면 테스트가 NUnit 테스트 어댑터에 표시되지 않습니다.


NUnit3 + 버전을 사용하는 경우 새로운 테스트 어댑터를 사용할 수 있습니다.

"도구-> 확장 및 업데이트-> 온라인"으로 이동하여 " NUnit3 테스트 어댑터"를 검색 한 다음 설치하십시오.


내 테스트 어셈블리는 64 비트입니다. Visual Studio 2012 상단의 메뉴 모음에서 '테스트'-> '테스트 설정'-> '기본 프로세서 아키텍처'-> 'X64'를 선택할 수있었습니다. 'Build'메뉴에서 'Rebuild Solution'후에 테스트 탐색기에서 모든 테스트를 볼 수있었습니다. 희망적으로 이것은 미래에 다른 누군가를 도울 것입니다 = D.


NUnit 버전이 일치하지 않는지 확인하십시오. 현재 사용 가능한 NUnit 테스트 어댑터는 NUnit 버전 2.6.4 이하에서만 작동합니다. 버전 3.x에서 NUnit을 다운 그레이드하려면 패키지 관리자 콘솔> 업데이트 패키지 NUnit -version 2.6.4로 이동하십시오.

http://jeremybytes.blogspot.co.ke/2015/11/review-of-unit-testing-makes-me-faster.html


내 상황에서 'NUnit3 테스트 어댑터'가 비활성화되었습니다. 다시 활성화하려면 메뉴로 이동하십시오.

도구-> 확장 및 업데이트 ...

왼쪽에서 'Installed'-> 'All'을 선택하십시오.

오른쪽 상단에서 'nunit'을 검색하십시오.

'NUnit3 Test Adapter'가 설치되어 있으면 찾은 항목과 함께 활성화 / 비활성화 할 수 있습니다.

여기에 이미지 설명을 입력하십시오


이 답변은 매우 기본적으로 보이지만 처음에는 완전히 명확하지 않았습니다. 솔루션을 다시 빌드하는 경우 솔루션을 빌드하도록 구성된 프로젝트 만 빌드합니다.Build -> Configuration Manager

이것은 내 문제였습니다. 빌드 구성 설정이나 테스트 프로젝트가 빌드되지 않은 원인이 무엇이든 (이전의 경우) 실수로 변경해야합니다. 그래서 Test Explorer창은 오래된 dll을보고있었습니다. 이 작업을 수행 한 후 Clean대부분의 테스트가 사라지고 다시 방문하지 않은 것을 보았을 때이 사건이 분명해 졌습니다 rebuild... bin폴더를 자세히 살펴보면 이 프로젝트가 전혀 빌드되지 않았다는 것이 밝혀졌습니다.


VS 2017 및 .net 코어를 사용하는 경우 여기 에서 말한 것처럼 테스트 프레임 워크 NUnit 3.6.1 , 테스트 실행기 NUnit3TestAdapter 3.8.0-alpha1 및 테스트 SDK Microsoft.NET.Test.Sdk 에 대한 참조를 추가해야합니다. 15.0.0 .


작업 설정 (솔루션에 따라 NUnit2 및 NUnit3 및 2012 년과 2017 년에 여러 버전의 Visual Studio)이 있었고 어느 ​​날 갑자기 작동이 중단되었습니다. 솔루션이나 VS 버전에서 테스트가 감지되지 않았습니다.

제 경우에는 삭제하는 데 도움이되었습니다 %localappdata%\Temp\VisualStudioTestExplorerExtensions. VS를 다시 시작한 후 모든 것이 이전과 같이 작동했습니다.


  1. 도구
  2. NuGet 패키지 관리자
  3. 솔루션 용 NuGet 패키지 관리
  4. 검색
  5. NUnitTestAdapter.WithFramework
  6. 테스트 빌드 / 실행을위한 Ctrl + R, A

여기에 이미지 설명을 입력하십시오

NUnitTestAdapter.WithFramework를 사용하면 NUnit 및 NUnit 어댑터 버전간에 불일치가 거의 없는지 확인합니다 (즉, "그냥 작동합니다").


[TestFixureSetUp] 및 [Test]가 명시되어 있는지 확인하십시오

시험 수업에서

견본:

namespace ClassLibrary1
{
   public class SimpleCalculator
   {
      public Calculator _calculator;
      [TestFixtureSetUp]
      public void initialize()
      {
         _calculator = new Calculator();
      }
      [Test]
      public void DivideTest()
      {
         int a = 10;
         int b = 2;
         int expectedValue = a/b;
         int actualValue = _calculator.Divide(a, b);
         Assert.AreEqual(expectedValue, actualValue, "Functionality not working properly!");
      }
   }   
}

One other cause to this problem is if you open a project from a mapped drive - Visual Studio handles such projects properly, but apparently Nunit doesn't support them.

Copying the project to a physical fixed the issue.


I also found that when I uninstalled nunit v3.2.1, the nunit framework reference for v3.2.1 was still in my project in solution explorer. Solution Explorer > ProjectName > References

If you right click it will show the version. Remove this Then Right click on References > Add Reference.

Search for the version 2.x version and add then rebuild solution.

That worked for me!


I experienced the problem mentioned by op

My case was that I was handed an old project and the tests were actually part of the system under test. I assume they were using the external test runner.

this task chain resolved the issue for me

  • created a test project,
  • moved the test files there
  • added references so the test project would compile
  • added the Nunit and Nunit adapter NuGet packages to the test project
  • recompiled

i was able to successfully run the Nunit tests.


If you are using the TestCaseSource attribute, ensure the source exists and respects the documentation, otherwise your tests will not be discovered.


I had to uninstall then re-install the xunit.runner.visualstudio nuget package. I tried this after trying all the above suggestions, so may be it was a mixture of things.


I had a similar issue where the tests where not being discovered. I had the correct version of NUnit, versions matched up between NUnit and adapter, and the tests where tagged correctly. I was running VS 2017 Enterprise not as an administrator. After starting VS as administrator the tests appeared.


I started a new solution with a test project in it, and compared it against my original, problem project. The original, for some reason, had an app.config in it. I excluded that file from the project and saw my tests reappear in the test explorer.


I had this problem too but the cause was different. I'm using VS2017 with F# 4.0.

Firstly, the console in Visual Studio does not give you enough details why the tests could not be found; it will just fail to the load the DLL with the tests. So use NUnit3console.exe on the command line as this gives you more details.

In my case, it was because the test adapter was looking for a newer version of the F# Core DLL (4.4.1.0) (F# 4.1) whereas I'm still using 4.4.0.0 (F# 4.0). So I just added this to the app.config of the test project:-

  <dependentAssembly>
    <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
  </dependentAssembly>

i.e. redirect to the earlier F# core.


I had the same problem, when suddenly any test didn't appeared on Test Explorer window. I has the updated version of "NUnit3TestAdapter"

and after lots of searches and efforts, I found that I need set the following values in project properties: [In Solution Explorer window: right click on Project > Properties] Under Build tab, set Platform=x64, and set Platform target=x86 or Any CPU Build the project and all tests will be appear on Test Explorer window.

Important note: I came to a solution after seeing the next msg in the output window:

"Test run will use DLL(s) built for framework Framework45 and platform X86. Following DLL(s) will not be part of run: AutomationTests.dll is built for Framework Framework45 and Platform X64."


I had some msbuild.exe processes that were hung. I don't know if that was my problem or not, but it took me a lot of trail and error with reinstalling various NUnit adaptors before I found the hung processes.


여기에 $ .02를 추가하기 위해 어제 비슷한 문제가 발생하여 168 개의 테스트가 누락되었습니다. 이 게시물에서 대부분의 모든 것을 시도했습니다. 특히 NUnit의 버전이 동일해야합니다. 그런 다음 테스트를 재생 목록으로 나눈 것을 기억했습니다. 이들은 하지 않는 새로운 테스트를 추가 할 때 자동으로 업데이트됩니다 . 재생 목록을 삭제하면 BAM! 모든 테스트가 다시 한 번 돌아 왔습니다.


테스트에 Test 속성이 올바르게 표시되어 있는지 확인하십시오. 모든 테스트에 Explicit 속성 만 표시되어 있으면 TestAdapter는 조명기를 인식하지 못합니다.

참고 URL : https://stackoverflow.com/questions/19298347/nunit-unit-tests-not-showing-in-test-explorer-with-test-adapter-installed

반응형