Using Web Unit Testing without AspNetDevelopmentServerHost

Answered Using Web Unit Testing without AspNetDevelopmentServerHost

  • mercredi 25 avril 2012 09:33
     
      A du code

    Hello,

    I have created a Web Application that I hosted in my local IIS under an url http://mysite.fr

    Said url is browsable through my navigator.

    I now want to do some web unit testing of its pages so I wrote a test with these attributes :

    [TestMethod]
    [HostType("ASP.NET")]
    [UrlToTest("http://mysite.fr/Default.aspx")] 
    But when executing the test I end up with the following exception : "The URL specified ('http://mysite.fr/Default.aspx') does not correspond to a valid directory. Tests configured to run in ASP.NET in IIS require a valid directory to exist for the URL. The URL may be invalid or may not point to a valid Web application."

    I saw in a lot of discussions that people tend to use "localhost" as a host header so I made my site in IIS respond through localhost:8081 which works in a navigator but not for my unit test (same error).

    Now I would like to know what am I doing wrong and how to fix that.

    And like the title of my topic said, no I cannot use the AspNetDevelopmentServerHost attribute to make it works because does not behave the same as IIS and can't make my site to work.

    Thanks and regards,
    Eric Gaspard.

Toutes les réponses

  • jeudi 26 avril 2012 10:50
     
     

    I tested my solution on other machines thinking that maybe there was something wrong in my configuration. I found out that on one it gives me the same error but on another one it works.

    The difference that I have identified (as for now) is that the working has an VS2010 Ultimate whether on the other two it's just a Premium edition.

    Therefore is there some kind of limitation for Premium edition that says that web unit test can only be done using ASP.NET Development Server ?

  • vendredi 27 avril 2012 05:19
    Modérateur
     
     

    Hi Eric,

    Thank you for posting in the MSDN forum.

    Based on your description, it seems that it worked in another computer which installed the VS2010 Ultimate, but it didn’t work in the VS 2010 Premium. If so, I’m afraid that it is not the unit test’s issue.

    Based on my understanding, the VS2010 Premium support the unit tests here, if possible, you could try to run it in another PC with the VS2010 Premium. If it works, I’m afraid that you could try to repair or reinstall your VS to check it. Of course, it will be better if you could install the VS2010 Ultimate, since it has more new features.

    Have a nice weekend,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

  • vendredi 27 avril 2012 07:15
     
     

    Hi Jack,

    Unit testing was never a problem with Premium, unit testing a website using ASP.NET Development Server (AspNetDevelopmentServerHost) works too but it is really when I want to use a website hosted in my local IIS that does not.

    I have tried to run my test on another computer running Visual Studio 2010 Premium and it did not work either. As I see in that chart Ultimate only incorporate "Web Testing" but I'm unsure what the term covers exactly. Is it "recording activity on web pages in order to replay it and expect the same result" or more simply "any testing requiring having a web context" ?

    Also if it was a problem of features not available in my version of VS, shouldn't I have a more straightforward message about it ?

    Thanks and have a nice weekend you too !
    Eric Gaspard.

  • vendredi 27 avril 2012 09:13
    Modérateur
     
     

    Hi Eric,

    Glad to receive your reply.

    Since I didn’t have the VS Premium in my current environment, I’m not very sure whether it is the product limit. If possible, I suggest you submit this feedback to Microsoft Connect feedback portal: http://connect.microsoft.com, Microsoft engineers will evaluate them seriously. I will vote it if I managed to reproduce this issue, anyway, thank you for sending feedback to us, it make Visual Studio better. Thanks for your understanding.

    In addition, if you want to know more information about the web test, you could refer this msdn document. Hope it could help.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

  • vendredi 27 avril 2012 10:21
     
     

    Hi Jack,

    On your recommendation I opened a feedback on Microsoft Connect which can be found here.

    As I understand Web Testing, which resemble instrumentation, this is not what I want to do. I only want to execute my test unit method with a web context.

    Thanks and regards,
    Eric Gaspard.

  • vendredi 1 février 2013 08:48
     
     Traitée

    Finally getting back to this one.

    As stated in this article (courtesy of Microsoft Connect) there is a prerequisite stating that you need the IIS 6 metabase and IIS 6 Configuration Compatibility installed to be able to use directly hosted website for you unit tests.

    Thanks and regards

    • Marqué comme réponse Eric Gaspard vendredi 1 février 2013 08:48
    •