1.使用Unit Test Wizard创建单元测试.不必说

2.Copy WebService项目下面的Web.config到单元测试项目下,改名App.config,如有需要修改修改相应配置

3.HostType 注释掉

4.UrlToTest 修改为指定的webservice url

如下:

        [TestMethod()]
       // [HostType("ASP.NET")] 注释掉
        [AspNetDevelopmentServerHost("E:\\Project\\Elp2.5\\source\\web\\ElpWeb\\ELPApp\\Elp.AppServices", "/")]
        [UrlToTest("http://localhost:3166/UserService.asmx")]//asmx地址
        public void LoginTest()
        {
            UserService target = new UserService(); // TODO: Initialize to an appropriate value
            string userName = "test"; // TODO: Initialize to an appropriate value
            string password = "edit"; // TODO: Initialize to an appropriate value
            bool actul=  target.Login(userName, password);
            Assert.AreEqual(true, actul);

           // Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

相关文章:

  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-09-23
  • 2021-10-23
  • 2022-01-13
猜你喜欢
  • 2021-07-28
  • 2021-10-21
  • 2021-06-07
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案