本文整理汇总了C#中TestRunner.RunTests方法的典型用法代码示例。如果您正苦于以下问题:C# TestRunner.RunTests方法的具体用法?C# TestRunner.RunTests怎么用?C# TestRunner.RunTests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestRunner
的用法示例。
在下文中一共展示了TestRunner.RunTests方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static int Main(string[] args)
{
Console.WindowWidth = 120;
var noPause = args.Contains("/nopause");
var runner = new TestRunner(errorFile: "_errors.log");
var configs = BuildServerConfigs();
int skipServerCount = 0;
var testRuns = runner.RunTests(typeof(Program).Assembly, configs,
// init action for server type; must return true to run the tests
cfg => {
Console.WriteLine();
Console.WriteLine(cfg.ToString());
SetupHelper.Reset(cfg);
// Check if server is available
string error;
if (ToolHelper.TestConnection(SetupHelper.Driver, SetupHelper.ConnectionString, out error)) return true;
runner.ConsoleWriteRed(" Connection test failed for connection string: {0}, \r\n Error: {1}", SetupHelper.ConnectionString, error);
skipServerCount++;
return false;
});
//Report results
var errCount = testRuns.Sum(tr => tr.Errors.Count) + skipServerCount;
Console.WriteLine();
if (errCount > 0)
runner.ConsoleWriteRed("Errors: " + errCount);
// stop unless there's /nopause switch
if (!noPause) {
Console.WriteLine("Press any key...");
Console.ReadKey();
}
return errCount == 0 ? 0 : -1;
}
示例2: Main
//private static StreamWriter logFile;
static void Main(string[] args)
{
//Quick Test Change
_testDllPaths = new List<string>();
//logFile = File.CreateText("C:\\LogFile.txt");
//logFile.AutoFlush = true;
//Console.WriteLine(Process.GetCurrentProcess().StartInfo.Arguments);
//logFile.WriteLine(Process.GetCurrentProcess().StartInfo.Arguments);
if (ParseArgs(args) == false)
{
return;
}
SetArgsIfNotSupplied();
if (CheckIfFilesExist() == false)
{
return;
}
ClearPreviousResultFiles();
var testRunner = new TestRunner(_msTestPath, _resultFolder, _coreCount, _runConfigPath);
foreach (var dllPath in _testDllPaths)
{
testRunner.AddAssembly(dllPath);
}
var start = DateTime.Now;
testRunner.RunTests();
var end = DateTime.Now;
var totalTime = end - start;
Console.WriteLine(totalTime);
if (_shouldCombineResultsFile == true)
{
MSTestXmlParser.CombineAllResultFiles(_resultFolder, "result", FinalResultFile);
if (MSTestXmlParser.DidAllTestsPass(FinalResultFile) == false)
{
Console.WriteLine("Not All Tests Passed check file: \"{0}\" to see which ones failed", FinalResultFile);
}
}
}
示例3: RunTestsInAssembly
void RunTestsInAssembly(List<ExecutorWrapper> cleanupList, string assemblyFileName, ITestExecutionRecorder recorder, IEnumerable<TestCase> testCases = null)
{
if (cancelled)
return;
var executor = new ExecutorWrapper(assemblyFileName, configFileName: null, shadowCopy: true);
cleanupList.Add(executor);
if (testCases == null)
testCases = VsTestRunner.GetTestCases(executor).ToArray();
var logger = new VsRunnerLogger(recorder, testCases, () => cancelled);
var runner = new TestRunner(executor, logger);
foreach (var testClass in testCases.Select(tc => new TypeAndMethod(tc.FullyQualifiedName))
.GroupBy(tam => tam.Type))
{
runner.RunTests(testClass.Key, testClass.Select(tam => tam.Method).ToList());
if (cancelled)
return;
}
}
示例4: RunTestsInAssembly
void RunTestsInAssembly(string assemblyFileName, IRunContext ctxt, ITestExecutionRecorder recorder, IEnumerable<TestCase> testCases = null)
{
cancelled = false;
using (var executor = new ExecutorWrapper(assemblyFileName, configFilename: null, shadowCopy: true)) {
if (testCases == null)
testCases = VsTestRunner.GetTestCases(executor).ToArray();
var logger = new VsRunnerLogger(recorder, testCases, () => cancelled);
var runner = new TestRunner(executor, logger);
foreach (var testClass in testCases.Select(tc => new TypeAndMethod(tc.Name))
.GroupBy(tam => tam.Type))
runner.RunTests(testClass.Key, testClass.Select(tam => tam.Method).ToList());
}
}