locked
Network Name cannot be found error when executing unit tests RRS feed

  • Question

  • Hi there,

    I'm not sure whether i should create another thread on on this issue.

    I am using MS Visual Studio 2012 Premium on Windows 7 Professional x64

    I am trying to run the unit tests against a WCF service installed on my machine. I am running it as localhost through Visual Studio.

    When i run the unit test from the UnitTest dll i am getting the following error:

    System.IO.IOException, The network name cannot be found

    The Unit Test class has a DeploymentItem attribute decorated such as the following:

    [TestClass]
    [DeploymentItem("FunctionalTests.config")]
    public class ProductTests
    {
      //unit tests here
    }

    I then modified the FunctionalTests.config file and modified the file to point to my service running locally and it still doesnt work.

    When i look at the generated results trx file it says "The network name cannot be found".

    Could anyone explain why i could be receiving this error please?

    Thanks,


    • Moved by Ego Jiang Thursday, May 30, 2013 7:57 AM
    Wednesday, May 29, 2013 11:12 AM

Answers

  • Hello,

    Glad to receive your reply.

    If you get this error when you run this test from command line with MSTest, will you still get this issue when you run test from VS IDE?

    Since you said you can’t get the error when you examine the log file, I would like to know whether test failed when you run it from VS. If so, does it fail at the same error? If possible please provide us detailed error messages if test run failed in VS IDE.

    In addition, I suggest that you try to use DeploymentItem attribute under  TestMethod attribute instead of TestClass and note that please put the deployed file in the unit test project folder and set ‘Copy to Output Directory’ to ‘Copy Always’ to check the result.

    And you can try the same scenario on another machine to see if you still can get this issue. Maybe the issue is related to test environment.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, June 5, 2013 10:30 AM
    Friday, May 31, 2013 2:27 AM

All replies

  • Hello,

    Thank you for your post.

    Whether you are running unit test from Command line using MSTest?

    If so, I suggest that you try to run test from VS IDE, will you see the same error? Whether unit test can run successfully?

    The error message does not look like a unit test error. Since the unit test is against a WCF service, I doubt that the issue is related to WCF service.

    Please check the WCF service to make sure unit test can interact with it well.

    In addition, can you provide more error information so that we can further look at this issue?

    If you get this issue when you run test from VS, you can enable logging for VS through http://social.msdn.microsoft.com/Forums/en-US/vstswebtest/thread/f6f77b5f-80da-4d4d-96e4-6dea56ef80e7 to see if you can get more useful information.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 30, 2013 8:16 AM
  • Hi Amanda,

    I am running the unit tests when i build the project through Visual Studio 2012 and the same error occurs. Behind the csproj file i wrote the following target. Here is the target i created:

    <Target Name="AfterBuild"> <Message Text="Running tests..." /> <PropertyGroup> <TestSuccessOrNot>1</TestSuccessOrNot> </PropertyGroup> <Exec Command='"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:C:\SampleProject\Main\_Libraries\FunctionalTests.dll /test:T15064 /detail:testname'> <Output TaskParameter="ExitCode" PropertyName="TestSuccessOrNot" /> </Exec> <Error Condition="$(TestSuccessOrNot) == 1" Text="Unit tests fail!" /> </Target>

    I have tried to run the unit test via command line but the same error occurs. I have tried to use the logging functionality by invoking devenv.exe and enabled the logging functionality:

    devenv.exe /log C:/Temp/log.xml

    I couldn't see the error that I wanted to see when i examined the log file.

    Any thoughts on the above?

    Thanks in advance


    • Edited by IndusKing Thursday, May 30, 2013 8:51 AM
    Thursday, May 30, 2013 8:50 AM
  • Hello,

    Glad to receive your reply.

    If you get this error when you run this test from command line with MSTest, will you still get this issue when you run test from VS IDE?

    Since you said you can’t get the error when you examine the log file, I would like to know whether test failed when you run it from VS. If so, does it fail at the same error? If possible please provide us detailed error messages if test run failed in VS IDE.

    In addition, I suggest that you try to use DeploymentItem attribute under  TestMethod attribute instead of TestClass and note that please put the deployed file in the unit test project folder and set ‘Copy to Output Directory’ to ‘Copy Always’ to check the result.

    And you can try the same scenario on another machine to see if you still can get this issue. Maybe the issue is related to test environment.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, June 5, 2013 10:30 AM
    Friday, May 31, 2013 2:27 AM
  • Hello,

    I am marking useful reply as answer. If the suggestion can’t help you, you can come back and unmark it as answer. If you have anything unclear, please feel free to come back and ask me.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, June 5, 2013 10:30 AM