Console.WriteLine()函数不起作用,会发生什么

Console.WriteLine()函数不起作用,会发生什么

问题描述:

我正在尝试编写一个演示应用程序,以使用代码来运行Nunit测试

I am try to write a demostrate application to use use code to run Nunit testing

我想使用remotetestrunner来运行测试.所以我创建一个控制台应用程序.

I am suppose to use remotetestrunner to run the test. so I create a Console application.

 课程计划
    {

 class Program
    {

       静态void Main(string [] args)
        {

        static void Main(string[] args)
        {

     Console.WriteLine(尝试运行NUnit测试DLL");
            TestResult slt = GetTSTRslt(@"C:\ Documents and Settings \ rgcao \ My Documents \ Visual Studio 2010 \ Projects \ DailyBuild \ DailyBuild \ bin \ Debug \ DailyBuilyTest.dll");
            Console.WriteLine(运行完成");
            Console.WriteLine(string.Format(运行状态为{0}",slt.ResultState.ToString()));
            //访问其他内容,例如通过了多少测试,失败了多少);

    Console.WriteLine("Try to run NUnit test DLL");
            TestResult slt = GetTSTRslt(@"C:\Documents and Settings\rgcao\My Documents\Visual Studio 2010\Projects\DailyBuild\DailyBuild\bin\Debug\DailyBuilyTest.dll");
            Console.WriteLine("Running Complete");
            Console.WriteLine(string.Format("Running Status is {0}", slt.ResultState.ToString() ));
            //visit some other something like how many test passed, how many failed );

            Console.ReadLine();

           Console.ReadLine();

         }

         }

       公共静态TestResult GetTSTRslt(string sDLL)
        {
            TestPackage testPackage =新的TestPackage(sDLL);
            RemoteTestRunner remoteTestRunner =新的RemoteTestRunner();
            remoteTestRunner.Load(testPackage);
            remoteTestRunner.BeginRun(new NullListener(),TestFilter.Empty,true,LoggingThreshold.All);
            remoteTestRunner.Wait();
            remoteTestRunner.EndRun();
            TestResult testResult = remoteTestRunner.TestResult;

        public static TestResult GetTSTRslt(string sDLL)
        {
            TestPackage testPackage = new TestPackage(sDLL);
            RemoteTestRunner remoteTestRunner = new RemoteTestRunner();
            remoteTestRunner.Load(testPackage);
            remoteTestRunner.BeginRun(new NullListener(), TestFilter.Empty, true, LoggingThreshold.All);
            remoteTestRunner.Wait();
            remoteTestRunner.EndRun();
            TestResult testResult = remoteTestRunner.TestResult;

           }

           }

}

执行后,我想得到3行

但是我只能得到一个,即尝试运行NUnit测试DLL". ,另外两条消息在哪里?

but I can only get one, the "Try to run NUnit test DLL" , where is the other two message?

我已经调试好GetTSTRslt函数可以正常工作,并且它确实返回了消息.为什么Console.WriteLine函数不能在屏幕上显示我的消息?

I have be debug that the GetTSTRslt function work fine, and it do return message. Why Console.WriteLine function do not display my message to screen?

有人可以帮助我吗?

我使用VS2010和Nunit 2.6.2开发

my developing using VS2010, and Nunit 2.6.2

非常感谢

ray

正在发生的全部事情是什么?

What is the full thing that is happening?

在第一个WriteLine之后,程序是否没有继续?它占用了CPU功率,您必须使用调试器或Taskmanager杀死它吗? Visual Studio是否在告诉您存在未隐藏的异常?

Is the programm not continuing after the first WriteLine? Is it taking up CPU Power and you have to kill it using the debugger or taskmanager? Is Visual Studio Telling you there was an unhadeled exception?