自動生成ログ


スクリプトの実行手順は、問題が発生するように、明確で制御可能であり、詳細なログ、結果出力が必要です.
自動化スクリプトは実行にとどまらず、結果を判断する能力も必要であり、異常に遭遇したら対応できる処理が必要である.だからログ出力の結果は重要です.
 
http://stackoverflow.com/questions/19966054/execute-command-line-statements-from-within-nunit
 
 
一.nunitを使用してログコードを自動的に実行できます
 

1.cmd进入到nunit-console.exe路径(或者配置环境变量)

2.  nunit-console.exe -h(-h help),        :

Options:/fixture=STR Test fixture or namespace to be loaded (Deprecated) (Short format:/load=STR)/run=STR Name of the test case(s), fixture(s) or namespace(s) torun/runlist=STR Name of a file containing a list of the tests to run, one per line/config=STR Project configuration (e.g.: Debug) to load/result=STR Name of XML result file (Default: TestResult.xml) (Short format:/xml=STR)/xmlConsole Display XML to the console (Deprecated)/noresult Suppress XML result output (Short format:/noxml)/output=STR File to receive test output (Short format:/out=STR)/err=STR File to receive test error output/work=STR Work directory for output files/labels Label each test in stdOut/trace=X Set internal trace level: Off, Error, Warning, Info, Verbose/include=STR List of categories to include/exclude=STR List of categories to exclude/framework=STR Framework version to be used for tests/process=X Process model for tests: Single, Separate, Multiple/domain=X AppDomain Usage for tests: None, Single, Multiple/apartment=X Apartment for running tests: MTA (Default), STA/noshadow Disable shadow copy when running in separate domain/nothread Disable use of a separate thread for tests/basepath=STR Base path to be used when loading the assemblies/privatebinpath=STR Additional directories to be probed when loading assemblies, separated by semicolons/timeout=X Set timeout for each test case in milliseconds/wait Wait for input before closing console window/nologo Do not display the logo/nodots Do not display progress/stoponerror Stop after the first test failure or error/cleanup Erase any leftover cache files and exit/help Display help (Short format:/?)
  :nunit-console.exe dll   /output d:\temp\log.txt(    console  )(  1)
nunit-console.exe dll   /result d:\temp\result.xml(  2)

1
         _ 1   

2
        _ 2
 

.

            string stamp = DateTime.Now.ToString("s");
            stamp = stamp.Replace(":", "-");
            string path1 = "d:\\temp\\TestResluts-" + stamp + ".txt";
          
            FileStream fsStream = new FileStream(path1, FileMode.Create);
            StreamWriter swWriter = new StreamWriter(fsStream);
            swWriter.WriteLine("" + caseID +"Pass");