locked
VS 2015 unit tests do not run in VS 2017 RRS feed

  • Question

  • I have a set of C unit tests, developed using VS 2015. I followed what I thought was the standard approach to developing the unit tests.

    Format of a typical test:

        BEGIN_TEST_METHOD_ATTRIBUTE(agent_lookup_msisdn_not_found)            TEST_RUNCLASS(L"Ad-hoc")      TEST_COMPONENT(L"Agent")      END_TEST_METHOD_ATTRIBUTE()      TEST_METHOD(agent_lookup_msisdn_not_found)

    I installed Visual Studio 2017 Enterprise, and Test Explorer shows a single list of 100 tests, with no "traits" being shown, and with the following errors:

    Cannot discover test extensions installed by NuGet. The NuGet service is not available. Tests may not be found due to missing test adapter extensions.------ Load Playlist started ------========== Load Playlist finished (0:00:00.003) ==========------ Discover test started ------Cannot discover test extensions installed by NuGet. The NuGet service is not available. Tests may not be found due to missing test adapter extensions.Cannot discover test extensions installed by NuGet. The NuGet service is not available. Tests may not be found due to missing test adapter extensions.========== Discover test finished: 100 found (0:00:02.002) ==========

    ...and I cannot run a test, with the same warning.

    I went to "Extensions and updates", did a search "online" for NuGet, and there is just "NuGet Package Project", which does not look like it is suitable.

    What do I need to do, to get my unit tests working?

    Wednesday, March 8, 2017 9:52 AM

All replies

  • Hi MLVJ,

    In my side, my VS2015 test methods could be identified in VS2017. And according to your error message “ Cannot discover test extensions installed by NuGet”, so whether in your project has the third test framework form the Nuget, if yes please do the following steps:

    1). Reopen the project in VS2017, and build it.

    2). Right-click the solution, click the Restore NeGet Packages, please refer to the following screenshot:

    Sincerely,

    Oscar


    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.

    Thursday, March 9, 2017 2:48 AM
  • Hi Oscar,

    Thank you very much for your reply.  I do not have the "Manage NuGet Packages for Solution" or "Restore NuGet Packages" in my menu.

    When I created the unit tests in MS VS 2015, I followed the instructions from this page:

    https://msdn.microsoft.com/en-us/library/hh598953.aspx

    I did not install any extensions - however I can see that on VS 2015, there IS NuGet Package Manager in the "Tools" Menu.

    ...therefore is there something wrong with the 2017 installation, that NuGet has failed to install? I just searched for NuGet in 2017 Extensions, and installed "NiuGet Package Project" - but that has seemingly made no difference - NuGet is not showing as an installed extension.

    Any suggestions? Thank you!

    Thursday, March 9, 2017 8:34 AM
  • Hi MLVJ,

    1). Please clean the solution and build it to see whether has the same issue.

    2). Set the platform as x64, then build it.

    Sincerely,

    Oscar


    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.

    Thursday, March 9, 2017 8:44 AM
  • I did the rebuild, and it is x64, no joy!

    Here is a REALLY simple single test example, one of the tests:

    #include "stdafx.h"#include "CppUnitTest.h"#include <CodeCoverage\CodeCoverage.h>using namespace Microsoft::VisualStudio::CppUnitTestFramework;namespace tst_mhs{            TEST_CLASS(UnitTestCache)    {    public:    BEGIN_TEST_METHOD_ATTRIBUTE(cache_db_flag_to_boolean_all_values)            TEST_RUNCLASS(L"Ad-hoc")      TEST_COMPONENT(L"Cache")      END_TEST_METHOD_ATTRIBUTE()        TEST_METHOD(cache_db_flag_to_boolean_all_values)        {      char db_flag;      for (db_flag = -128; db_flag < 127; db_flag++)      {        if (db_flag == 'Y')        {          Assert::AreEqual(cache_db_flag_to_boolean(db_flag), (t_boolean)TRUE);        }        else        {          Assert::AreEqual(cache_db_flag_to_boolean(db_flag), (t_boolean)FALSE);        }      }    }};}

    Is there anything that requires NuGet?

    Thursday, March 9, 2017 9:02 AM
  • Hi MLVJ,

    According to your above code, I could not help you repro your issue in my side.

    but you could add a new empty test method, and copy these code to this method to see the results. :)

    Sincerely,

    Oscar


    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.


    • Edited by Oscar_Wu Thursday, March 9, 2017 9:17 AM
    Thursday, March 9, 2017 9:17 AM
  • I created a new file, which is contained in entirety:#include "stdafx.h"

    #include "stdafx.h"
    #include "CppUnitTest.h"
    #include <CodeCoverage\CodeCoverage.h>
    
    using namespace Microsoft::VisualStudio::CppUnitTestFramework;
    
    namespace tst_mhs
    {
    	TEST_CLASS(UnitTestFormat)
    	{
    	public:
    
    		BEGIN_TEST_METHOD_ATTRIBUTE(test)
    
    			END_TEST_METHOD_ATTRIBUTE()
    
    			TEST_METHOD(test)
    		{
    
    			Assert::AreEqual(0, 1);
    		}
    	};
    }

    ...and that has the same problem still.

    I did a search for "nuget" in my entire project tree, and there are no matches - which tells me that the project itself does not have a link to nuget.

    The test itself shows up in the Test Explorer, but cannot be run due to the "NuGet service is not available".

    Would you have a simple test that I could paste in, see if I can run? Perhaps the macros are incorrect.
    Thursday, March 9, 2017 10:14 AM
  • Hi friend,

    In your test project, whether you are using Test Controller? The following thread has the same issue as yours, you could refer to it.

    http://stackoverflow.com/questions/24639214/visual-studio-2012-unit-tests-not-running-remotly-because-of-nuget-error

    Hope it helpful for you.

    Sincerely,

    Oscar


    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.

    Monday, March 13, 2017 1:46 PM
  • Thanks - that is not applicable to me.

    I think there is something wrong with the visual studio 2017 installation - I tried to create a new test project, and vs 2017 hung.

    Monday, March 13, 2017 7:10 PM
  • Hi MLVJ,

    There is an update for VS2017, I suggest you could update the VS2017 and try again.

    And this issue happened just installed VS2017, so I suggest you had better repair the VS2017 and to see again.

    Sincerely,

    Oscar


    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, March 15, 2017 1:51 AM
  • Thanks. No luck with the new update yet.

    I have also raised an issue using the "Send Feedback" option in VS 2017 - they suggested creating a new unit test file, which hung.

    I did try creating a completely new empty solution - and that allowed me to create a very simple unit test - and that ran - but when I imported the existing project, then from that point it all stopped working again.

    Wednesday, March 15, 2017 11:43 AM
  • Hi MLVJ,

    I could not reproduce your issue in my side, and I have found the report you submitted from the following screenshot.

    You could mark this reply, that could be helpful for others who have the same issue to vote and comment it.

    Sincerely,

    Oscar


    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.


    • Edited by Oscar_Wu Thursday, March 16, 2017 7:37 AM
    • Proposed as answer by Oscar_Wu Friday, March 17, 2017 9:52 AM
    • Unproposed as answer by MLVJ- Friday, March 17, 2017 11:46 AM
    Thursday, March 16, 2017 3:06 AM
  • I cannot mark anything as the answer - the problem with VS 2017 not running existing VS 2015 unit tests is unresolved - still fails.

    I have had no feedback from the VS 2017 issue that I raised.

    What are you proposing as the answer?

    Friday, March 17, 2017 11:46 AM
  • Hi MLVJ,

    I followed your steps again, created a Native C++ Test project with VS2015, and open it with VS2017, I could run it without any problems. And here is my version of VS2017 : VisualStudio/15.0.0+26228.9.

    Here is my project, you could download it and try again in your side:

    https://1drv.ms/f/s!AiYjxW6ElFsyzEPImTNW1OSnlXgo

    In addition, please view the all logs of applications in our machine. Please refer to the following steps:

    Click Start->Right-click This PC->More->Manage->System Tools->Event Viewer->double-click Application

    Then all logs of applications are displayed in list box. Please view whether has logs of Visual Studio.

    Sincerely,

    Oscar


    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.

    Monday, March 20, 2017 7:19 AM
  • I missed this reply, when you posted it, weeks ago! Apologies.

    I have tried this; and INTERESTING.

    The issue is partially reproduced. I:

    1) downloaded your project, unzipped

    2) opened in VS2015, ran the test (successfully)

    3) closed from VS2015; opened in VS2017, declined offer to retarget. VS2017 reported:

    Cannot discover test extensions installed by NuGet. The NuGet service is not available. Tests may not be found due to missing test adapter extensions.

    4) Ran test, which reports green, but I get that message. I edited the test to be "Assert:Fail();" - and that caused a failure to be reported, so we know the test is actually running.

    I looked in the Event Log (cleared before runs) - and there do not seem to be ANY Event logs relating to VS2017.

    What else can I do?

    Wednesday, May 10, 2017 1:19 PM