NUnitLite web下的用法

using NUnitLite.Framework;
using NUnitLite.Constraints;
using NUnitLite.Runner;
public class testWeb : System.Web.UI.Page
	{
		
		
	
		private void Page_Load(object sender, EventArgs e)
		{

			
			/*
			 清除Response,并且把类型赋值为txt文本类型,
			 因为NUnitLite是文本输出,浏览器默认是html方式的,
			 所以回车之类都没有效果看起来不方便
			 */
			Response.ClearContent();
			Response.ClearHeaders();
			Response.Clear();
			Response.ContentType="text/plain";

			/*
			 把Console输出流改成Response.Output,这样测试类里用Console.WriteLine就可以看见了
			 */
			Console.SetOut(this.Response.Output);

			/*
			 以下是NUnitLite的测试入口
			 */
			CommandLineOptions options = new CommandLineOptions();
			ConsoleUI runner = new ConsoleUI(options, this.Response.Output);
			TestResult result = runner.Run(System.Reflection.Assembly.GetExecutingAssembly());

			Response.End();
		}
}

老系统是net1.1 而且耦合度不太好,反正要脱离web系统测试数据操作很麻烦,想测试只能找NunitLite了,而且资料很少,NunitLite的主页也没啥文档说明,只能google了,找了下网上别人都是用于Compact的测试,摸索了一下大致能行,N年前搞过一次成功的,后来忘记了怎么弄了,只能在摸索一下,赶快写篇blog。

ps:NunitLite我只能用最老的0.1.0,现在都到0.6.0了,不过是net 2.0不能用。另外
    [TestFixture()],[Test()]之类不能写description太麻烦了。

原文地址:https://www.cnblogs.com/peteryu007/p/2133728.html