本文整理汇总了C#中TestRunner类的典型用法代码示例。如果您正苦于以下问题:C# TestRunner类的具体用法?C# TestRunner怎么用?C# TestRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestRunner类属于命名空间,在下文中一共展示了TestRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getRunItemsFor
private string[] getRunItemsFor(TestRunner runner, List<TestToRun> runList)
{
var query = from t in runList
where t.Runner.Equals(runner) || t.Runner.Equals(TestRunner.Any)
select t.Test;
return query.ToArray();
}
示例2: TestResult
public TestResult(TestRunner runner, TestRunStatus status, string name)
{
_runner = runner;
_name = name;
_status = status;
_stackTrace = new IStackLine[] { };
}
示例3: GetTestsFor
public string[] GetTestsFor(TestRunner runner)
{
var query = from t in _testsToRun
where t.Runner.Equals(runner) || t.Runner.Equals(TestRunner.Any)
select t.Test;
return query.ToArray();
}
示例4: TestRunnerThread
public TestRunnerThread( TestRunner runner )
{
this.runner = runner;
this.thread = new Thread( new ThreadStart( TestRunnerThreadProc ) );
thread.IsBackground = true;
thread.Name = "TestRunnerThread";
this.settings = (NameValueCollection)
ConfigurationSettings.GetConfig( "NUnit/TestRunner" );
if ( settings != null )
{
try
{
string apartment = settings["ApartmentState"];
if ( apartment != null )
thread.ApartmentState = (ApartmentState)
System.Enum.Parse( typeof( ApartmentState ), apartment, true );
string priority = settings["ThreadPriority"];
if ( priority != null )
thread.Priority = (ThreadPriority)
System.Enum.Parse( typeof( ThreadPriority ), priority, true );
}
catch( ArgumentException ex )
{
string msg = string.Format( "Invalid configuration setting in {0}",
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile );
throw new ArgumentException( msg, ex );
}
}
}
示例5: Main
public static int Main(string[] args)
{
// parse the command line
CommandLineArguments cmdLine = CommandLineParser.Parse(new string[] {}, args);
if(cmdLine.GetArguments().Length != 1)
{
Usage();
return FAIL_CODE;
}
string testFile = cmdLine.GetArguments()[0];
// parse the test file
TestGroup[] groups = null;
try
{
XmlDocument doc = new XmlDocument();
doc.Load(testFile);
// Load up the algorithm tables
Hashtable algorithms = ParseAlgorithms((XmlElement)doc.GetElementsByTagName("HashFunctions")[0]);
// Load the test cases
groups = ParseTestCases((XmlElement)doc.GetElementsByTagName("Tests")[0], algorithms);
}
catch(Exception e)
{
Console.Error.WriteLine("Error parsing input file : " + e.Message);
return FAIL_CODE;
}
// setup the tests
TestRunner runner = new TestRunner(groups, new ILogger[] { new ConsoleLogger(), new XmlLogger()});
return runner.Run("HashDriver") ? PASS_CODE : FAIL_CODE;
}
示例6: using
TestRunState ITdNetTestRunner.RunMember(ITestListener listener, Assembly assembly, MemberInfo member)
{
try
{
using (ExecutorWrapper wrapper = new ExecutorWrapper(new Uri(assembly.CodeBase).LocalPath, null, false))
{
TdNetLogger logger = new TdNetLogger(listener, assembly);
TestRunner runner = new TestRunner(wrapper, logger);
MethodInfo method = member as MethodInfo;
if (method != null)
return RunMethod(runner, method);
Type type = member as Type;
if (type != null)
return RunClassWithInnerTypes(runner, type);
return TestRunState.NoTests;
}
}
catch (ArgumentException)
{
return TestRunState.NoTests;
}
}
示例7: OnNavigatedTo
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
try
{
TestRunner runner = new TestRunner();
Block.DataContext = runner;
IFileTester[] testers =
{
/*new FileExistsTester(),
new IsolatedStorageFileFileExistsTester(),
new StorageFolderGetFileAsyncTester(),
new StorageFileGetFileFromPathAsyncTester(),
new StorageFileGetFileFromApplicationUriAsyncTester(),
new StorageFolderGetFilesAsyncTester(),*/
new StorageFolderGetFileSyncTester(),
new StorageFileGetFileFromPathSyncTester(),
new StorageFileGetFileFromApplicationUriSyncTester(),
};
await runner.InitFiles(500, 0);
await runner.RunTest(testers);
await runner.InitFiles(500, 0.5);
await runner.RunTest(testers);
await runner.InitFiles(500, 1);
await runner.RunTest(testers);
}
catch (Exception exception)
{
Debug.WriteLine(exception);
}
}
示例8: 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;
}
示例9: RunTestsButton_Click
private async void RunTestsButton_Click(object sender, RoutedEventArgs e)
{
this.RunTestsButton.IsEnabled = false;
this.TestRunProgress.Visibility = Visibility.Visible;
this.TextSummaryText.Visibility = Visibility.Collapsed;
try
{
var testRunner = new TestRunner(Assembly.GetExecutingAssembly());
await TaskEx.Run(() => testRunner.RunTestsAsync());
this.TextSummaryText.Text = string.Format(
CultureInfo.CurrentCulture,
"{0}/{1} tests passed ({2}%)",
testRunner.PassCount,
testRunner.TestCount,
100 * testRunner.PassCount / testRunner.TestCount);
this.TextSummaryText.Visibility = Visibility.Visible;
this.ResultsTextBox.Text = testRunner.Log;
}
catch (Exception ex)
{
this.ResultsTextBox.Text = ex.ToString();
}
finally
{
this.RunTestsButton.IsEnabled = true;
this.TestRunProgress.Visibility = Visibility.Collapsed;
}
}
示例10: TestRunnerThread
public TestRunnerThread( TestRunner runner )
{
this.runner = runner;
this.thread = new Thread( new ThreadStart( TestRunnerThreadProc ) );
this.settings = (NameValueCollection)
ConfigurationSettings.GetConfig( "NUnit/TestRunner" );
try
{
string apartment = (string)settings["ApartmentState"];
if ( apartment == "STA" )
thread.ApartmentState = ApartmentState.STA;
else if ( apartment == "MTA" )
thread.ApartmentState = ApartmentState.MTA;
string priority = (string)settings["ThreadPriority"];
if ( priority != null )
thread.Priority = (ThreadPriority)
System.Enum.Parse( typeof( ThreadPriority ), priority, true );
}
catch
{
// Ignore any problems for now - test will run using default settings
}
}
示例11: TestFailure
public TestFailure(string assembly, string className, string testName, TestRunner runner)
{
Assembly = assembly;
ClassName = className;
TestName = testName;
Runner = runner;
}
示例12: Parallelize
protected void Parallelize() {
string executable = Environment.GetCommandLineArgs()[0];
RunFromConsole = executable.ToLower().Contains("nunit-console");
foreach (MethodInfo methodInfo in GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance)) {
if (methodInfo.GetCustomAttributes(typeof(TestAttribute), false).Length == 1 &&
methodInfo.GetCustomAttributes(typeof(IgnoreAttribute), false).Length == 0) {
string key = GetKey(methodInfo);
MethodInfo actionMethod = GetType().GetMethod(key + "Action",
BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
if (actionMethod != null) {
actions.Add(key, () => actionMethod.Invoke(this, new object[] { }));
}
}
}
if (RunFromConsole) {
foreach (KeyValuePair<string, Action> actionPair in actions) {
TestRunner testRunner = new TestRunner(actionPair.Value);
ThreadStart ts = testRunner.DoWork;
Thread thread = new Thread(ts);
testRunner.Thread = thread;
thread.Start();
threads.Add(actionPair.Key, testRunner);
}
}
}
示例13: RunTest
public void RunTest(DataUpdateDelegate graphUpdate, float stopVoltage, int readingDelay, int stepSize, string outFile)
{
TestRunner runner = new TestRunner(graphUpdate, stopVoltage, readingDelay, stepSize, outFile);
Thread tThread = new Thread(new ThreadStart(runner.RunTest));
KeepRunningTest = true;
tThread.Start();
}
示例14: HasTestSuitesProperty
public static void HasTestSuitesProperty(TestRunner r)
{
harness.FindTests();
string foundName = harness.TestSuites[sampleSuiteName].Name;
r.Expect(foundName).ToBe(sampleSuiteName);
}
示例15: GetTestsReturnsAllTestsInSampleSuite
public static void GetTestsReturnsAllTestsInSampleSuite(TestRunner r)
{
harness.FindTests();
List<TestRunner> testsFound = harness.GetTestsInSuite(sampleSuiteName);
r.Expect(testsFound.Count).ToBe(2);
}