如何在ASP.NET Web应用程序中运行单元测试 [英] How to run unit test in asp.net web application

查看:262
本文介绍了如何在ASP.NET Web应用程序中运行单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hai朋友,
任何人都可以在asp.net中提供逐步进行单元测试的过程.
我创建了一个示例Web应用程序,它具有用于单元测试的简单功能..
但它显示错误,例如



运行测试"Button1_ClickTest"时,测试适配器"WebHostAdapter"引发异常.网站配置不正确;获取ASP.NET进程信息失败.请求``http://localhost:1832/VSEnterpriseHelper.axd''返回错误:远程服务器返回错误:(500)Internal Server Error.
远程服务器返回了一个错误:(500)Internal Server Error.

hai friends,
can any one provide step by step process for unit test in asp.net.
i have created a sample web application with a simple function for unit test..
but it displaying error like



The test adapter ''WebHostAdapter'' threw an exception while running test ''Button1_ClickTest''. The web site could not be configured correctly; getting ASP.NET process information failed. Requesting ''http://localhost:1832/VSEnterpriseHelper.axd'' returned an error: The remote server returned an error: (500) Internal Server Error.
The remote server returned an error: (500) Internal Server Error.

推荐答案

将其放在您的web.config中:
Put this in your web.config:
<customerrors defaultredirect="Error.aspx" mode="Off" />


错误500太笼统而无法诊断.

完成此操作后,它将为您提供精确的位置信息,从而导致您的网站出现异常,从这一点上,您可能可以确定问题并加以解决.

从外观上看,似乎wResp可能为null,或者从wResp.GetResponseStream返回的值可能为null.在代码周围放置try/catch块将是一个好主意...

尝试以下链接将对您有所帮助:-

http://stackoverflow.com/questions/260432/500- error-running-visual-studio-asp-net-unit-test [ http://forums.asp.net/t/1411782.aspx/1 [ ^ ]


Error 500 is too generic to diagnose.

Once you do that, it will give you the precise locatoion that is causing your site to misbehave, and from that point, you can probably identify the problem and fix it.

From the looks of it though, it seems that wResp might be null, or the returned value from wResp.GetResponseStream might be null. Putting a try/catch block around the code would be a good idea...

try these links will be helpful to you:-

http://stackoverflow.com/questions/260432/500-error-running-visual-studio-asp-net-unit-test[^]

http://forums.asp.net/t/1411782.aspx/1[^]


这篇关于如何在ASP.NET Web应用程序中运行单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆