Unit Test for ASP.NET Application

This is my first test for the Asp.Net web application. We have an engine consisting of several modules. I need to check the classes in the Engine module. Although these classes are part of the Asp.Net application, they consist only of business logic.

How can I test these classes while others are part of WebApp? because i get this error

The web request http: // localhost: 8936 / completed successfully without running the test. This can happen if the web application setup for testing fails (an ASP.NET server error occurs while processing the request) or when the ASP.NET page fails (the URL may point to an HTML page, web service or directory list). Running tests in ASP.NET requires that the URL resolve to the ASP.NET page and that the page runs correctly before the load event. The response from the request is stored in the file "WebRequestResponse_BlogManagerBPOConstr.html" with the test results; you can usually open this file using a web browser to view its contents.

thank

EDIT: @Mark, this is one of the TestMethod methods created by the designer

/

// <summary>
        ///A test for BlogManagerBPO Constructor
        ///</summary>
        // TODO: Ensure that the UrlToTest attribute specifies a URL to an ASP.NET page (for example,
        // http://.../Default.aspx). This is necessary for the unit test to be executed on the web server,
        // whether you are testing a page, web service, or a WCF service.
        [TestMethod()]
        [HostType("ASP.NET")]
        [AspNetDevelopmentServerHost("D:\\WorkingCopies\\MyProject\\Engine", "/")]
        [UrlToTest("http://localhost:8936/")]
        public void BlogManagerBPOConstructorTest()
        {
            BlogManagerBPO target = new BlogManagerBPO();
            Assert.Inconclusive("TODO: Implement code to verify target");
        }
+3
4

, , unit test. Visual Studio Web Test?

- ASP.NET.

MsTest :

[TestMethod]
public void Test5()
{
    var sut = new Thing();
    var expectedResult = new object();
    sut.Bar = expectedResult;
    var actual = sut.Bar;
    Assert.AreEqual(expectedResult, actual);
}

(, , ...)

ASP.NET .

, - , System.Web ..

+5

UrlToTest Url In. :

[TestMethod()]
[HostType("ASP.NET")]
[AspNetDevelopmentServerHost("C:\\xx\\xx\\Documents\\Visual Studio 2010\\Projects\\xx\\xx", "/")]
[UrlToTest("http://localhost:xxx/examples.aspx")]
[DeploymentItem("examples.dll")]
+2

Or, as Mark said, get rid of.
   [HostType("ASP.NET")] [AspNetDevelopmentServerHost("C:\xx\xx\Documents\Visual Studio 2010\Projects\xx\xx", "/")] [UrlToTest("http://localhost:xxx/examples.aspx")] [DeploymentItem("examples.dll")] I tried to use it in the MVC project, and he did not go through until I got rid of it.

+1
source

Just check if you have added app.config to your test project and it has the necessary settings from your web.config (from the WebService project).

0
source

Source: https://habr.com/ru/post/1728202/


All Articles