本文整理汇总了C#中IFrameworkHandle类的典型用法代码示例。如果您正苦于以下问题:C# IFrameworkHandle类的具体用法?C# IFrameworkHandle怎么用?C# IFrameworkHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFrameworkHandle类属于命名空间,在下文中一共展示了IFrameworkHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunTests
// NOTE: an earlier version of this code had a FilterBuilder
// property. This seemed to make sense, because we instantiate
// it in two different places. However, the existence of an
// NUnitTestFilterBuilder, containing a reference to an engine
// service caused our second-level tests of the test executor
// to throw an exception. So if you consider doing this, beware!
#endregion
#region ITestExecutor Implementation
/// <summary>
/// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
/// to run either all or selected tests. In the latter case, a filter is provided
/// as part of the run context.
/// </summary>
/// <param name="sources">Sources to be run.</param>
/// <param name="runContext">Context to use when executing the tests.</param>
/// <param name="frameworkHandle">Test log to send results and messages through</param>
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
#if LAUNCHDEBUGGER
if (!Debugger.IsAttached)
Debugger.Launch();
#endif
Initialize(runContext, frameworkHandle);
try
{
foreach (var source in sources)
{
var assemblyName = source;
if (!Path.IsPathRooted(assemblyName))
assemblyName = Path.Combine(Environment.CurrentDirectory, assemblyName);
TestLog.Info("Running all tests in " + assemblyName);
RunAssembly(assemblyName, TestFilter.Empty);
}
}
catch (Exception ex)
{
if (ex is TargetInvocationException)
ex = ex.InnerException;
TestLog.Error("Exception thrown executing tests", ex);
}
finally
{
TestLog.Info(string.Format("NUnit Adapter {0}: Test execution complete", AdapterVersion));
Unload();
}
}
示例2: RunTests
/// <summary>
/// Runs the tests.
/// </summary>
/// <param name="tests">Which tests should be run.</param>
/// <param name="context">Context in which to run tests.</param>
/// <param param name="framework">Where results should be stored.</param>
public void RunTests(IEnumerable<TestCase> tests, IRunContext context, IFrameworkHandle framework)
{
_state = ExecutorState.Running;
foreach (var test in tests)
{
if (_state == ExecutorState.Cancelling)
{
_state = ExecutorState.Cancelled;
return;
}
try
{
var reportDocument = RunOrDebugCatchTest(test.Source, test.FullyQualifiedName, context, framework);
var result = GetTestResultFromReport(test, reportDocument, framework);
framework.RecordResult(result);
}
catch (Exception ex)
{
// Log it and move on. It will show up to the user as a test that hasn't been run.
framework.SendMessage(TestMessageLevel.Error, "Exception occured when processing test case: " + test.FullyQualifiedName);
framework.SendMessage(TestMessageLevel.Informational, "Message: " + ex.Message + "\nStacktrace:" + ex.StackTrace);
}
}
}
示例3: RunTests
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
this.frameworkHandle = frameworkHandle;
var testLogger = new TestLogger(frameworkHandle);
testLogger.SendMainMessage("Execution started");
foreach (var group in tests.GroupBy(t => t.Source))
{
testLogger.SendInformationalMessage(String.Format("Running selected: '{0}'", group.Key));
try
{
using (var sandbox = new Sandbox<Executor>(group.Key))
{
var assemblyDirectory = new DirectoryInfo(Path.GetDirectoryName(group.Key));
Directory.SetCurrentDirectory(assemblyDirectory.FullName);
sandbox.Content.Execute(this, group.Select(t => t.FullyQualifiedName).ToArray());
}
}
catch (Exception ex)
{
testLogger.SendErrorMessage(ex, String.Format("Exception found while executing tests in group '{0}'", group.Key));
// just go on with the next
}
}
testLogger.SendMainMessage("Execution finished");
}
示例4: RunTests
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
//Debugger.Launch();
frameworkHandle.SendMessage(TestMessageLevel.Informational, Strings.EXECUTOR_STARTING);
Settings settings = GetSettings(runContext);
foreach (string currentAsssembly in sources.Distinct())
{
try
{
if (!File.Exists(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(currentAsssembly)),"Machine.Specifications.dll")))
{
frameworkHandle.SendMessage(TestMessageLevel.Informational, String.Format("Machine.Specifications.dll not found for {0}", currentAsssembly));
continue;
}
frameworkHandle.SendMessage(TestMessageLevel.Informational, String.Format(Strings.EXECUTOR_EXECUTINGIN, currentAsssembly));
this.executor.RunAssembly(currentAsssembly, settings, uri, frameworkHandle);
}
catch (Exception ex)
{
frameworkHandle.SendMessage(TestMessageLevel.Error, String.Format(Strings.EXECUTOR_ERROR, currentAsssembly, ex.Message));
}
}
frameworkHandle.SendMessage(TestMessageLevel.Informational, String.Format("Complete on {0} assemblies ", sources.Count()));
}
示例5: RunTests
public void RunTests(IEnumerable<string> sources, IRunContext runContext,
IFrameworkHandle frameworkHandle)
{
SetupExecutionPolicy();
IEnumerable<TestCase> tests = PowerShellTestDiscoverer.GetTests(sources, null);
RunTests(tests, runContext, frameworkHandle);
}
示例6: RunTests
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
Guard.ArgumentNotNull("sources", sources);
Guard.ArgumentNotNull("runContext", runContext);
Guard.ArgumentNotNull("frameworkHandle", frameworkHandle);
var cleanupList = new List<ExecutorWrapper>();
try
{
RemotingUtility.CleanUpRegisteredChannels();
cancelled = false;
foreach (string source in sources)
if (VsTestRunner.IsXunitTestAssembly(source))
RunTestsInAssembly(cleanupList, source, frameworkHandle);
}
finally
{
Thread.Sleep(1000);
foreach (var executorWrapper in cleanupList)
executorWrapper.Dispose();
}
}
示例7: RunTests
/// <summary>
/// Called by the Visual Studio IDE to run all tests. Also called by TFS Build
/// to run either all or selected tests. In the latter case, a filter is provided
/// as part of the run context.
/// </summary>
/// <param name="sources">Sources to be run.</param>
/// <param name="runContext">Context to use when executing the tests.</param>
/// <param name="frameworkHandle">Test log to send results and messages through</param>
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
testLog.Initialize(frameworkHandle);
Info("executing tests", "started");
try
{
// Ensure any channels registered by other adapters are unregistered
CleanUpRegisteredChannels();
var tfsfilter = new TFSTestFilter(runContext);
testLog.SendDebugMessage("Keepalive:" + runContext.KeepAlive);
if (!tfsfilter.HasTfsFilterValue && runContext.KeepAlive)
frameworkHandle.EnableShutdownAfterTestRun = true;
foreach (var source in sources)
{
using (currentRunner = new AssemblyRunner(testLog, source, tfsfilter))
{
currentRunner.RunAssembly(frameworkHandle);
}
currentRunner = null;
}
}
catch (Exception ex)
{
testLog.SendErrorMessage("Exception " + ex);
}
finally
{
Info("executing tests", "finished");
}
}
示例8: RunTests
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
IMessageLogger log = frameworkHandle;
log.Version();
HandlePoorVisualStudioImplementationDetails(runContext, frameworkHandle);
foreach (var assemblyPath in sources)
{
try
{
if (AssemblyDirectoryContainsFixie(assemblyPath))
{
log.Info("Processing " + assemblyPath);
var listener = new VisualStudioListener(frameworkHandle, assemblyPath);
using (var environment = new ExecutionEnvironment(assemblyPath))
{
environment.RunAssembly(new Options(), listener);
}
}
else
{
log.Info("Skipping " + assemblyPath + " because it is not a test assembly.");
}
}
catch (Exception exception)
{
log.Error(exception);
}
}
}
示例9: RunTests
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
frameworkHandle.SendMessage(TestMessageLevel.Informational, Strings.EXECUTOR_STARTING);
int executedSpecCount = 0;
string currentAsssembly = string.Empty;
try
{
ISpecificationExecutor specificationExecutor = this.adapterFactory.CreateExecutor();
IEnumerable<IGrouping<string, TestCase>> groupBySource = tests.GroupBy(x => x.Source);
foreach (IGrouping<string, TestCase> grouping in groupBySource)
{
currentAsssembly = grouping.Key;
frameworkHandle.SendMessage(TestMessageLevel.Informational, string.Format(Strings.EXECUTOR_EXECUTINGIN, currentAsssembly));
specificationExecutor.RunAssemblySpecifications(currentAsssembly, MSpecTestAdapter.uri, runContext, frameworkHandle, grouping);
executedSpecCount += grouping.Count();
}
frameworkHandle.SendMessage(TestMessageLevel.Informational, String.Format(Strings.EXECUTOR_COMPLETE, executedSpecCount, groupBySource.Count()));
}
catch (Exception ex)
{
frameworkHandle.SendMessage(TestMessageLevel.Error, string.Format(Strings.EXECUTOR_ERROR, currentAsssembly, ex.Message));
}
finally
{
}
}
示例10: RunTests
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
ChutzpahTracer.TraceInformation("Begin Test Adapter Run Tests");
var settingsProvider = runContext.RunSettings.GetSettings(AdapterConstants.SettingsName) as ChutzpahAdapterSettingsProvider;
var settings = settingsProvider != null ? settingsProvider.Settings : new ChutzpahAdapterSettings();
ChutzpahTracingHelper.Toggle(settings.EnabledTracing);
var testOptions = new TestOptions
{
TestLaunchMode =
runContext.IsBeingDebugged ? TestLaunchMode.Custom:
settings.OpenInBrowser ? TestLaunchMode.FullBrowser:
TestLaunchMode.HeadlessBrowser,
CustomTestLauncher = runContext.IsBeingDebugged ? new VsDebuggerTestLauncher() : null,
MaxDegreeOfParallelism = runContext.IsBeingDebugged ? 1 : settings.MaxDegreeOfParallelism,
ChutzpahSettingsFileEnvironments = new ChutzpahSettingsFileEnvironments(settings.ChutzpahSettingsFileEnvironments)
};
testOptions.CoverageOptions.Enabled = runContext.IsDataCollectionEnabled;
var callback = new ParallelRunnerCallbackAdapter(new ExecutionCallback(frameworkHandle, runContext));
testRunner.RunTests(sources, testOptions, callback);
ChutzpahTracer.TraceInformation("End Test Adapter Run Tests");
}
示例11: RunTests
/// <summary>
/// Runs the tests.
/// </summary>
/// <param name="tests">Tests to be run.</param>
/// <param name="runContext">Context to use when executing the tests.</param>
/// <param param name="frameworkHandle">Handle to the framework to record results and to do framework operations.</param>
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
m_cancelled = false;
try
{
foreach (TestCase test in tests)
{
if (m_cancelled)
{
break;
}
frameworkHandle.RecordStart(test);
frameworkHandle.SendMessage(TestMessageLevel.Informational, "Starting external test for " + test.DisplayName);
var testOutcome = RunExternalTest(test, runContext, frameworkHandle, test);
frameworkHandle.RecordResult(testOutcome);
frameworkHandle.SendMessage(TestMessageLevel.Informational, "Test result:" + testOutcome.Outcome.ToString());
}
}
catch(Exception e)
{
frameworkHandle.SendMessage(TestMessageLevel.Error, "Exception during test execution: " +e.Message);
}
}
示例12: RunTests
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
List<TestCase> tests = new List<TestCase>();
TestDiscoverer.VisitTests(sources, t => tests.Add(t));
InternalRunTests(tests, runContext, frameworkHandle, null);
}
示例13: RunTests
private void RunTests(string source, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
foreach (var result in ExternalTestExecutor.GetTestResults(source, null).Select(c => CreateTestResult(source, c)))
{
frameworkHandle.RecordStart(result.TestCase);
frameworkHandle.RecordResult(result);
frameworkHandle.RecordEnd(result.TestCase, result.Outcome);
}
}
示例14: Debug
public virtual void Debug(BoostTestRunnerCommandLineArgs args, BoostTestRunnerSettings settings, IFrameworkHandle framework)
{
Utility.Code.Require(settings, "settings");
using (Process process = Debug(framework, GetStartInfo(args, settings)))
{
MonitorProcess(process, settings.Timeout);
}
}
示例15: RunTests
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle) {
ValidateArg.NotNull(tests, "tests");
ValidateArg.NotNull(runContext, "runContext");
ValidateArg.NotNull(frameworkHandle, "frameworkHandle");
_cancelRequested.Reset();
RunTestCases(tests, runContext, frameworkHandle);
}