none
"NUnit 2 Test Adapter" - Visual Studio TestExplorer fails to discover test cases RRS feed

  • Question

  • I have both Visual Studio 2015 and Visual Studio 2017 installed on my PC.
    I am trying to get the "NUnit 2 Test Adapter" work with either VS2015/2017 but facing some problems.

    I have installed the "NUnit 2 Test Adapter" extension but when I open an existing solution which contains
    projects with NUnit test cases and build it, the test cases doesnt list in the TestExplorer of visual studio.
    I tried this with csharp projects and C++/CLI(managed c++) project - both didnt work.

    But when I create a new csharp project/ C++/CLI project and refer the same NUnit framework and write test cases,
    or even copy test cases from the existsing project to the new project - the tests starts listsing in the TestExplorer.

    I am not able to figure out whats wrong with my existing NUnit project that the tests are not getting discovered in the
    test explorer.

    Please Help!
    Thank you.
    Monday, June 10, 2019 4:19 AM

All replies

  • Hi manju_v,

    Welcome to MSDN forum.

    According to your description, it seems that the existing project lack some nuget packages. Please follow below steps to check them:

    #1 right-click the project >> select the Manage Nuget Packages...

    #2 check if these nuget packages exist under installed

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, June 11, 2019 4:02 AM
  • For the C++/CLI project installation of NuGet package failed with error -

    Could not install package 'Microsoft.NET.Test.Sdk 16.1.1'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

    For CSharp project NuGet package installation was successful but there is another error as below -

    Successfully installed 'Microsoft.NET.Test.Sdk 16.1.1' to projectname
    Failed to update binding redirects for projectname : Error HRESULT E_FAIL has been returned from a call to a COM component.

    For the new projects which I created the TestExplorer is working even without the Test SDK NuGet package installed, but not with my existing projects


    Detailed Package Manager Output is as below :

    When tried to add Microsoft.NET.Test.Sdk to a C++/CLI project:


    Attempting to gather dependency information for package 'Microsoft.NET.Test.Sdk.16.1.1' with respect to project 'TestFrame\ProjectName', targeting 'native,Version=v0.0'
    Attempting to resolve dependencies for package 'Microsoft.NET.Test.Sdk.16.1.1' with DependencyBehavior 'Lowest'
    Resolving actions to install package 'Microsoft.NET.Test.Sdk.16.1.1'
    Resolved actions to install package 'Microsoft.NET.Test.Sdk.16.1.1'
    Install failed. Rolling back...
    Package 'Microsoft.NET.Test.Sdk.16.1.1' does not exist in project 'ProjectName'
    Removing package 'Microsoft.NET.Test.Sdk.16.1.1' from folder 'E:\WS\FolderName\packages'
    Removed package 'Microsoft.NET.Test.Sdk.16.1.1' from folder 'E:\WS\FolderName\packages'
    Could not install package 'Microsoft.NET.Test.Sdk 16.1.1'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
    ========== Finished ==========


    When tried to add Microsoft.NET.Test.Sdk to a CSharp project:

    Attempting to gather dependency information for package 'Microsoft.NET.Test.Sdk.16.1.1' with respect to project 'foldername\projectname', targeting '.NETFramework,Version=v4.6.1'
    Attempting to resolve dependencies for package 'Microsoft.NET.Test.Sdk.16.1.1' with DependencyBehavior 'Lowest'
    Resolving actions to install package 'Microsoft.NET.Test.Sdk.16.1.1'
    Resolved actions to install package 'Microsoft.NET.Test.Sdk.16.1.1'
    Package 'Microsoft.CodeCoverage.16.1.1' already exists in folder 'E:\WS\foldername\packages'
    Added package 'Microsoft.CodeCoverage.16.1.1' to 'packages.config'
    Successfully installed 'Microsoft.CodeCoverage 16.1.1' to projectname
    Package 'Microsoft.NET.Test.Sdk.16.1.1' already exists in folder 'E:\WS\foldername\packages'
    Added package 'Microsoft.NET.Test.Sdk.16.1.1' to 'packages.config'
    Successfully installed 'Microsoft.NET.Test.Sdk 16.1.1' to projectname
    Failed to update binding redirects for projectname : Error HRESULT E_FAIL has been returned from a call to a COM component.
    ========== Finished ==========


    Tuesday, June 18, 2019 7:01 AM
  • Hi manju_v,

    Thank you for reply.

    As your log, you may clear the caches for your project AFTER BACK UP YOUR PROJECT, then rebuild them

    NOTE:  Please right-click your project, then rebuild your project.

    If this issue persists, could you share the existing project with one or no test method using one drive or github, then I will download and test in my side, and I will give a solution as soon as possible.

    Look forward to your reply.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, June 19, 2019 9:15 AM
  • Hello Dylan,

    The issue still persists even after rebuilding the projects.

    I cant share the project due to my company's policies.
    If u can suggest any logs to be enabled before building the projects,
    I can provide you those logs.

    Thank you!
    Thursday, June 20, 2019 11:23 AM
  • Hi manju_v,

    Thank you for reply.

    For C++/CLR: without installing nuget packages, you could re-add the Nunit.dll as reference, then rebuild it.

    For C#: uninstall nuget package, delete the bin and obj file, re-install the four nuget packages , then rebuild it

    Note: When you delete, please back up your project.

    If there is update information, please feel free to contact me.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, June 21, 2019 10:17 AM
  • Hello Dylan,

    Sorry for the late reply.

    I am working with C++/CLI project and Re-adding NUnit dll as reference worked :) The tests started listing in the test explorer. Thank you very much for your help.

    The test code is under TFS source control. Do I need to remove - re-add the NUnit dll everytime I need to run the tests or is there a permanent solution for this ?

    Best Regards,

    Manjunath

    Wednesday, June 26, 2019 2:05 AM
  • Hi manju_u,

    Thank you for feedback.

    From your reply, the Nunit test should not be referenced to the project as normal. Does this reference refer to the project in an absolute address? If so, please change it to relative path with your project.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Wednesday, June 26, 2019 8:30 AM
  • Hello Dylan,

    

    Thanks for your reply and sorry for the late response. I was on leave because of some emergency.
    I have added the NUnit Dll as a reference in the project and have given a relative path as below:

    <Reference Include="nunit.framework">
          <HintPath>..\..\..\..\..\..\..\packages\NUnit.3.10.1\lib\net45\nunit.framework.dll</HintPath>
          <Private>false</Private>
          <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
          <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
    </Reference>

    If I make the <Private> (copy local in Visual Studio) as True, the test cases get detected, else they dont.
    Is this an issue with Visual Studio Test Explorer or the NUnitTestAdapter?

    Thank you,

    Manjunath

    Thursday, July 25, 2019 12:16 PM
  • Hi manju_v,

    Thank you for reply.

    As far as I know, the option is used to make the dll could follow the project, and copy automatically the dll to output directory.

    If the nunit has located in the specified path, then you change it to false, did the test case get detected?

    Or please try to reference Nunit.dll which is from output path, then change it to false, and check if the test case could get detected. 

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, July 26, 2019 9:16 AM