public void SetUp() { test = TestUtility.ReadTest( @" <Test name='some test'> <EmbeddedSection> <Grammar1 /> <DoSomeArithmetic> <Arithmetic> <StartWith starting='100' /> <MultiplyBy multiplier='2' /> <TheValueShouldBe expected='200' /> <Subtract operand='50' /> <TheValueShouldBe expected='150' /> <Throw /> <TheValueShouldBe expected='1' /> </Arithmetic> </DoSomeArithmetic> <Grammar2 /> </EmbeddedSection> </Test> "); runner = new TestRunner(); }
public PreparingTestRunner(int threadId, string solutionDirectory, ITestFrameworkReporter reporter, TestEnvironment testEnvironment) { _testEnvironment = testEnvironment; _innerTestRunner = new SequentialTestRunner(reporter, _testEnvironment); _threadId = threadId; _solutionDirectory = solutionDirectory; }
public TestPage() { _testRunner = VitaUnitRunner.GetService<ITestRunner>(); _testRunner.AllTestsCompleted += OnAllTestsCompleted; InitializeWidget(); InitializeTestResultPanel(); }
public static ITestOutput RegisterAsClient(ITestRunner runner, Options options) { ServiceHost host = new ServiceHost(runner); int i; for (i = 1; i < 51; i += 10) { try { host.AddServiceEndpoint(typeof(ITestRunner), BindingFactory(), "http://localhost:" + (StartPort + i) + "/"); break; } catch (AddressAlreadyInUseException) { } } host.Open(); var start = DateTime.Now; Exception final = null; var res = new ChannelFactory<ITestOutput>(BindingFactory(), "http://localhost:" + (StartPort + i - 1) + "/").CreateChannel(); while (DateTime.Now - start < TimeSpan.FromSeconds(5)) { try { res.Ping(); return res; } catch (Exception e) { final = e; } } throw final; }
public void SetUp() { _project = new Project(Path.GetFullPath("someProject.csproj"), new ProjectDocument(ProjectType.CSharp)); _project.Value.SetOutputPath(""); _project.Value.SetAssemblyName("someAssembly.dll"); _bus = MockRepository.GenerateMock<IMessageBus>(); _listGenerator = MockRepository.GenerateMock<IGenerateBuildList>(); _configuration = MockRepository.GenerateMock<IConfiguration>(); _buildRunner = MockRepository.GenerateMock<IBuildRunner>(); _testRunner = MockRepository.GenerateMock<ITestRunner>(); _testAssemblyValidator = MockRepository.GenerateMock<IDetermineIfAssemblyShouldBeTested>(); _optimizer = MockRepository.GenerateMock<IOptimizeBuildConfiguration>(); _runInfo = new RunInfo(_project); _runInfo.ShouldBuild(); _runInfo.SetAssembly(_project.Value.AssemblyName); _optimizer.Stub(o => o.AssembleBuildConfiguration(new string[] {})).IgnoreArguments().Return(new RunInfo[] { _runInfo }); _preProcessor = MockRepository.GenerateMock<IPreProcessTestruns>(); _preProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new RunInfo[] { _runInfo }); var preProcessors = new IPreProcessTestruns[] { _preProcessor }; var buildPreProcessor = MockRepository.GenerateMock<IPreProcessBuildruns>(); buildPreProcessor.Stub(x => x.PreProcess(null)).IgnoreArguments().Return(new RunInfo[] { _runInfo }); var buildPreProcessors = new IPreProcessBuildruns[] { buildPreProcessor }; _removedTestLocator = MockRepository.GenerateMock<ILocateRemovedTests>(); _consumer = new ProjectChangeConsumer(_bus, _listGenerator, _configuration, _buildRunner, new ITestRunner[] { _testRunner }, _testAssemblyValidator, _optimizer, preProcessors, _removedTestLocator, buildPreProcessors); }
public void SetUp() { test = TestUtility.ReadTest( @" <Test name='some test'> <EmbeddedSection> <Grammar1 /> <DoSomeArithmetic> <Arithmetic> <StartWith starting='100' /> <MultiplyBy multiplier='2' /> <TheValueShouldBe expected='200' /> <Subtract operand='50' /> <TheValueShouldBe expected='150' /> <Throw /> <TheValueShouldBe expected='1' /> </Arithmetic> </DoSomeArithmetic> <Grammar2 /> </EmbeddedSection> </Test> "); runner = TestRunnerBuilder.For(x => x.AddFixturesFromThisAssembly()); }
public ChutzpahTestContainerDiscoverer(IServiceProvider serviceProvider, IChutzpahSettingsMapper settingsMapper, ILogger logger, ISolutionEventsListener solutionListener, ITestFilesUpdateWatcher testFilesUpdateWatcher, ITestFileAddRemoveListener testFilesAddRemoveListener, ITestRunner testRunner, IFileProbe fileProbe) { initialContainerSearch = true; cachedContainers = new List<ITestContainer>(); this.serviceProvider = serviceProvider; this.settingsMapper = settingsMapper; this.logger = logger; this.testRunner = testRunner; this.fileProbe = fileProbe; this.solutionListener = solutionListener; this.testFilesUpdateWatcher = testFilesUpdateWatcher; this.testFilesAddRemoveListener = testFilesAddRemoveListener; this.testFilesAddRemoveListener.TestFileChanged += OnProjectItemChanged; this.testFilesAddRemoveListener.StartListeningForTestFileChanges(); this.solutionListener.SolutionUnloaded += SolutionListenerOnSolutionUnloaded; this.solutionListener.SolutionProjectChanged += OnSolutionProjectChanged; this.solutionListener.StartListeningForChanges(); this.testFilesUpdateWatcher.FileChangedEvent += OnProjectItemChanged; }
/// <summary> /// Default constructor that initializes the console and it's formatters, as /// well as a list of commands used. /// </summary> public TestRunnerAction() { runner = new CSpecTestRunner(); formatter = new ConsoleFormatter(); console = new CSpecConsole(formatter); Commands = new List<ICommand>() { new Commands.RunnerAllCommand() }; }
public void SetUp() { mockTestRunner = MockRepository.GenerateMock<ITestRunner>(); var container = new ObjectContainer(); container.RegisterInstanceAs(mockTestRunner); steps = new StepsTestableHelper(); ((IContainerDependentObject)steps).SetObjectContainer(container); }
public LineCoverageCalc(ITestExplorer testExplorer, ICompiler compiler, ITestRunner testRunner) { _testExplorer = testExplorer; _compiler = compiler; _testRunner = testRunner; }
public static IWebDriver Create(ITestRunner testRunner) { switch (testRunner.Environment.Browser.Type) { case BrowserType.Firefox: default: return(new SeleniumFirefoxWebDriver(testRunner)); } }
public virtual void Listen(ITestRunner <TTestMethod> runner) { runner.TestFailed += TestFailed; runner.TestPassed += TestPassed; runner.TestsStarting += TestsStarting; runner.TestStarting += TestStarting; runner.TestsFinished += TestsFinished; runner.TestFinished += TestFinished; }
public TestController(IConfiguration configuration, ITestRunner testRunner, ITestDataIOManager testDataIOManager, ITestDataPrepocessor loadTestDataPreprocessor, ITestModifier testModifier) { _configuration = configuration; _loadTestRunner = testRunner; _loadTestDataIOManager = testDataIOManager; _loadTestDataPreprocessor = loadTestDataPreprocessor; _loadTestModifier = testModifier; }
private void StubTestRunnerFactory() { var testRunnerFactory = MockRepository.GenerateStub<ITestRunnerFactory>(); testRunner = MockRepository.GenerateStub<ITestRunner>(); testRunnerEvents = MockRepository.GenerateStub<ITestRunnerEvents>(); testRunner.Stub(tr => tr.Events).Return(testRunnerEvents); testRunnerFactory.Stub(trf => trf.CreateTestRunner()).Return(testRunner); testController.SetTestRunnerFactory(testRunnerFactory); }
public DirectoryRunner(ITestRunner runner, ITestReader reader, IResultsSummary summary, IFileSystem system, DirectoryRunnerSetup setup) { _runner = runner; _reader = reader; _summary = summary; _system = system; _setup = setup; }
private int RunTests(TestPackage package, TestFilter filter) { // TODO: We really need options as resolved by engine for most of these DisplayRequestedOptions(); // TODO: Incorporate this in EventCollector? RedirectOutputAsRequested(); TestEventHandler eventHandler = new TestEventHandler(options, outWriter, errorWriter); XmlNode result = null; // Save things that might be messed up by a bad test TextWriter savedOut = Console.Out; TextWriter savedError = Console.Error; DateTime startTime = DateTime.Now; try { using (new ColorConsole(ColorStyle.Output)) #if true result = engine.Run(package, eventHandler, filter); #else using (ITestRunner runner = engine.GetRunner(package)) { if (runner.Load(package)) { engineResult = runner.Run(eventHandler, testFilter); } } #endif } finally { Console.SetOut(savedOut); Console.SetError(savedError); RestoreOutput(); } //Console.WriteLine(); ResultReporter reporter = new ResultReporter(result, options); reporter.ReportResults(); // TODO: Inject this? var outputManager = new OutputManager(result, this.workDirectory); foreach (var outputSpec in options.ResultOutputSpecifications) { outputManager.WriteResultFile(outputSpec, startTime); } return(reporter.Summary.ErrorsAndFailures); }
static HttpClientTestFramework () { extensions = AddinManager.GetExtensionObjects<IHttpClientHandler> (); defaultRunner = new DefaultTestRunner (); var list = new List<ITestRunner> (); for (int i = 0; i < extensions.Length; i++) list.Add (new ExtensionTestRunner (extensions [i])); extensionRunners = list.ToArray (); }
public async Task <TestResult> Run(ITestRunner runner, string command, string argument) { TestResult result = null; LastRun = DateTime.Now; WasRun = true; Result = await runner.Run(command, argument, Input, ExpectedOutput, Timeout); return(result); }
public void CreateTestDebugger_UnknownProjectPassedToCreateTestRunnerMethod_DoesNotThrowNullReferenceException() { MockCSharpProject project = new MockCSharpProject(); project.FileName = @"d:\projects\test.unknown"; ITestRunner testRunner = testFrameworks.CreateTestDebugger(project); Assert.IsNull(testRunner); }
public override async Task InsertAsync(ITestRunner testRunner) { await testRunner.InsertTemplateAsync(User); UserAddress1["UserId"] = User.Identity; await testRunner.InsertTemplateAsync(UserAddress1); UserAddress2["UserId"] = User.Identity; await testRunner.InsertTemplateAsync(UserAddress2); }
public void SetUp() { _bus = MockRepository.GenerateMock<IMessageBus>(); _testRunner = MockRepository.GenerateMock<ITestRunner>(); _testAssemblyValidator = MockRepository.GenerateMock<IDetermineIfAssemblyShouldBeTested>(); _preProcessor = MockRepository.GenerateMock<IPreProcessTestruns>(); var preProcessors = new IPreProcessTestruns[] { _preProcessor }; _consumer = new AssemblyChangeConsumer(new ITestRunner[] { _testRunner }, _bus, _testAssemblyValidator, preProcessors); _testRunner.Stub(r => r.RunTests(null)).IgnoreArguments().Return(new TestRunResults[] {}); }
protected virtual async Task InitializeBindingRegistryAsync(ITestRunner testRunner) { BindingAssemblies = GetBindingAssemblies(); BuildBindingRegistry(BindingAssemblies); EventHandler domainUnload = delegate { OnDomainUnloadAsync().Wait(); }; AppDomain.CurrentDomain.DomainUnload += domainUnload; AppDomain.CurrentDomain.ProcessExit += domainUnload; }
private void StubTestRunnerFactory() { var testRunnerFactory = MockRepository.GenerateStub <ITestRunnerFactory>(); testRunner = MockRepository.GenerateStub <ITestRunner>(); testRunnerEvents = MockRepository.GenerateStub <ITestRunnerEvents>(); testRunner.Stub(tr => tr.Events).Return(testRunnerEvents); testRunnerFactory.Stub(trf => trf.CreateTestRunner()).Return(testRunner); testController.SetTestRunnerFactory(testRunnerFactory); }
public MainViewModel(ISelectFileDialog fileSelector, IMessageDialog messageDialog, ITestRunner runner) { _fileSelector = fileSelector; _messageDialog = messageDialog; _runner = runner; StartTestcasesCommand = new RelayCommand <object>((nullArgument) => StartTestCases().ConfigureAwait(false)); LoadTestcasesCommand = new RelayCommand <object>((nullArgument) => LoadTestCases()); ShowTestDetailsCommand = new RelayCommand <TestCase>((testCase) => _messageDialog.ShowMessage($"Erwartet:{Environment.NewLine}{string.Join(Environment.NewLine, testCase.Result.ExpectedOutput)}{Environment.NewLine}{Environment.NewLine}Ausgegeben:{Environment.NewLine}{string.Join(Environment.NewLine, testCase.Result.Output)}", "CodeRunner", MessageDialogIcons.Info)); }
private TestResults RunTests(TestPackage package, TestFilter filter, Messages.OnMessage[] messageSubscribers) { XmlNode result; using (new SaveConsoleOutput()) using (ITestRunner runner = _engine.GetRunner(package)) using (var ms = new MemoryStream()) using (var output = CreateOutputWriter(ms)) { try { var labels = "ON"; var eventHandler = new TestEventHandler(output, labels, messageSubscribers); result = runner.Run(eventHandler, filter); var reporter = new ResultReporter(result, output, _options); reporter.ReportResults(); output.Flush(); if (reporter.Summary.UnexpectedError) { return(new TestResults(TestResults.Code.UnexpectedError, GetResultText(ms), reporter.Summary)); } return(new TestResults(reporter.Summary.InvalidAssemblies > 0 ? TestResults.Code.InvalidAssembly : GetCode(reporter.Summary.FailureCount + reporter.Summary.ErrorCount + reporter.Summary.InvalidCount), GetResultText(ms), reporter.Summary)); } catch (NUnitEngineException ex) { output.WriteLine(ex.Message); output.Flush(); return(new TestResults(TestResults.Code.InvalidArg, GetResultText(ms))); } catch (FileNotFoundException ex) { output.WriteLine(ex.Message); output.Flush(); return(new TestResults(TestResults.Code.InvalidAssembly, GetResultText(ms))); } catch (DirectoryNotFoundException ex) { output.WriteLine(ex.Message); output.Flush(); return(new TestResults(TestResults.Code.InvalidAssembly, GetResultText(ms))); } catch (Exception ex) { output.WriteLine(ex.ToString()); output.Flush(); return(new TestResults(TestResults.Code.UnexpectedError, GetResultText(ms))); } } }
public void Run(object waitHandle) { ManualResetEvent handle = null; if (waitHandle != null) { handle = (ManualResetEvent)waitHandle; } AppDomain childDomain = null; try { var configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile; if (File.Exists(_assembly.Assembly + ".config")) { configFile = _assembly.Assembly + ".config"; } // Construct and initialize settings for a second AppDomain. AppDomainSetup domainSetup = new AppDomainSetup() { ApplicationBase = Path.GetDirectoryName(_assembly.Assembly), ConfigurationFile = configFile, ApplicationName = AppDomain.CurrentDomain.SetupInformation.ApplicationName, LoaderOptimization = LoaderOptimization.MultiDomainHost }; // Create the child AppDomain used for the service tool at runtime. Logger.Write("Starting sub domain"); childDomain = AppDomain.CreateDomain(_plugin.Type + " app domain", null, domainSetup); // Create an instance of the runtime in the second AppDomain. // A proxy to the object is returned. ITestRunner runtime = (ITestRunner)childDomain.CreateInstanceFromAndUnwrap(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath, typeof(TestRunner).FullName); //typeof(TestRunner).Assembly.FullName, typeof(TestRunner).FullName); // Prepare assemblies Logger.Write("Preparing resolver"); runtime.SetupResolver(_shouldLog); // start the runtime. call will marshal into the child runtime appdomain Program.AddResults(runtime.Run(_plugin, _id, new RunSettings(_assembly, _categories.ToArray(), _pipeName))); } catch (Exception ex) { Program.AddResults(ErrorHandler.GetError("Run", ex)); } finally { unloadDomain(childDomain); if (handle != null) { handle.Set(); } Program.WriteNow("Finished running tests for " + _assembly.Assembly); } }
private int RunTests(TestPackage package, TestFilter filter) { foreach (var spec in _options.ResultOutputSpecifications) { var outputPath = Path.Combine(_workDirectory, spec.OutputPath); GetResultWriter(spec).CheckWritability(outputPath); } // TODO: Incorporate this in EventCollector? RedirectErrorOutputAsRequested(); var labels = _options.DisplayTestLabels != null ? _options.DisplayTestLabels.ToUpperInvariant() : "ON"; XmlNode result; try { using (new SaveConsoleOutput()) using (new ColorConsole(ColorStyle.Output)) using (ITestRunner runner = _engine.GetRunner(package)) using (var output = CreateOutputWriter()) { var eventHandler = new TestEventHandler(output, labels, _options.TeamCity); result = runner.Run(eventHandler, filter); } } finally { RestoreErrorOutput(); } var writer = new ColorConsoleWriter(!_options.NoColor); var reporter = new ResultReporter(result, writer, _options); reporter.ReportResults(); foreach (var spec in _options.ResultOutputSpecifications) { var outputPath = Path.Combine(_workDirectory, spec.OutputPath); GetResultWriter(spec).WriteResultFile(result, outputPath); _outWriter.WriteLine("Results ({0}) saved as {1}", spec.Format, spec.OutputPath); } if (reporter.Summary.UnexpectedError) { return(ConsoleRunner.UNEXPECTED_ERROR); } return(reporter.Summary.InvalidAssemblies > 0 ? ConsoleRunner.INVALID_ASSEMBLY : reporter.Summary.FailureCount + reporter.Summary.ErrorCount + reporter.Summary.InvalidCount); }
protected NetworkTestRunner(ITestOutputHelper output) { TestRunner = TestManager.CreateInstance(output) .WithNewPsScriptFilename($"{GetType().Name}.ps1") .WithProjectSubfolderForTests("ScenarioTests") .WithCommonPsScripts(new[] { @"Common.ps1", @"../AzureRM.Resources.ps1", }) .WithNewRmModules(helper => new[] { helper.RMProfileModule, helper.GetRMModulePath("AzureRM.Monitor.psd1"), helper.GetRMModulePath("AzureRM.Network.psd1"), helper.GetRMModulePath("AzureRM.Compute.psd1"), helper.GetRMModulePath("AzureRM.Storage.psd1"), helper.GetRMModulePath("AzureRM.Sql.psd1"), helper.GetRMModulePath("AzureRM.ContainerInstance.psd1"), helper.GetRMModulePath("AzureRM.OperationalInsights.psd1"), helper.GetRMModulePath("AzureRM.KeyVault.psd1"), helper.GetRMModulePath("AzureRM.ManagedServiceIdentity.psd1"), helper.GetRMModulePath("AzureRM.PrivateDns.psd1"), }) .WithNewRecordMatcherArguments( userAgentsToIgnore: new Dictionary <string, string> { { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" }, }, resourceProviders: new Dictionary <string, string> { { "Microsoft.Resources", null }, { "Microsoft.Compute", null }, { "Microsoft.Features", null }, { "Microsoft.Authorization", null }, { "Microsoft.Network", null }, { "Microsoft.Storage", null }, { "Microsoft.Sql", null }, { "Microsoft.KeyVault", null }, { "Microsoft.ManagedServiceIdentity", null }, { "Microsoft.PrivateDns", null }, } ).WithManagementClients( GetResourceManagementClient, GetManagedServiceIdentityClient, GetKeyVaultManagementClient, GetNetworkManagementClient, GetComputeManagementClient, GetStorageManagementClient, GetKeyVaultClient, GetAzureRestClient, GetPrivateDnsManagementClient ) .Build(); }
public void CreateTestDebuggerReturnsNewTestRunnerFromCorrectTestFramework() { MockCSharpProject project = new MockCSharpProject(); project.FileName = @"d:\projects\test.csproj"; ITestRunner testDebugger = testFrameworks.CreateTestDebugger(project); ITestRunner[] expectedTestRunners = new ITestRunner[] { testDebugger }; Assert.AreEqual(expectedTestRunners, nunitTestFramework.TestDebuggersCreated.ToArray()); }
public virtual void FeatureSetup() { testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); var featureInfo = new FeatureInfo( new CultureInfo("en-US"), "Euclid agents provide metadata", "In order to satisfy requests for metadata\r\nAs an agent\r\nI need to provide metadat" + "a in arbitrary formats", ProgrammingLanguage.CSharp, new[] { "SdkSpecs", "MetadataService", "AgentMetadata" }); testRunner.OnFeatureStart(featureInfo); }
public void SetUp() { mockTestRunner = MockRepository.GenerateMock<ITestRunner>(); fakeAsyncTestExecutor = new FakeAsyncTestExecutor(); asyncTestRunner = new AsyncTestRunner(mockTestRunner); asyncTestRunner.RegisterAsyncTestExecutor(fakeAsyncTestExecutor); var scenarioInfo = new ScenarioInfo("sample scenario"); ObjectContainer.ScenarioContext = new ScenarioContext(scenarioInfo, mockTestRunner); asyncTestRunner.OnScenarioStart(scenarioInfo); }
public void write_some_html() { Project project = StoryTeller.Testing.DataMother.MathProject(); ITestRunner runner = project.LocalRunner(); Test test = project.LoadTests().GetAllTests().First(); runner.RunTest(test); test.OpenResultsInBrowser(); }
public Batch ( CommandServiceProvider <Batch> serviceProvider, ITestRunner testRunner, ProgramInfo programInfo ) : base(serviceProvider, nameof(Batch)) { _testRunner = testRunner; _programInfo = programInfo; }
public TestAuditor( ITestRunner testRunner, IAttributeUtility attributeUtility, IBattleRepository battleRepository, IPlayerRepository playerRepository) { this.testRunner = testRunner; this.attributeUtility = attributeUtility; this.battleRepository = battleRepository; this.playerRepository = playerRepository; }
public AbstractTestConfigManager(TestConfig TestConfig, IObjectFactory Factory) { this.TestConfig = TestConfig; this.Agent = Factory; _testCaseRepository = this.Agent.GetTestCaseRepository(this.TestConfig); _testRunner = this.Agent.GetTestRunnerByTestConfig(this.TestConfig); _reportProcessor = this.Agent.GetReportManagerByTestConfig(this.TestConfig); this.Agent.LogUtil.LogMessage(string.Format("Filtering test cases for {0} ...", TestConfig.ID)); this.FillDataMembersRelatedToTestCaseSelectionCriteria(); }
/// <summary> /// Executes the command. /// Hooks all runner events to the console to display all possible information /// from the runner. /// </summary> /// <param name="console"></param> /// <param name="actionParams"></param> public void Execute(CSpecConsole console, params object[] actionParams) { if (actionParams[0] is ITestRunner) { ITestRunner runner = (ITestRunner)actionParams[0]; runner.BeforeOperation += x => console.WriteTestName(x); runner.Operation += x => console.WriteTestDescription(x); runner.AfterOperation += x => console.WriteTestResult(x); } }
/// <summary> /// Returns an xml representation of the tests specified /// by a TestPackage. /// </summary> /// <param name="package">A TestPackage.</param> /// <returns>An XmlNode representing the tests.</returns> public ITestEngineResult Explore(TestPackage package, TestFilter filter) { using (ITestRunner runner = GetRunner()) { ITestEngineResult loadResult = runner.Load(package); return(loadResult.HasErrors ? loadResult : runner.Explore(filter)); } }
/// <summary> /// Default constructor that initializes the console and it's formatters, as /// well as a list of commands used. /// </summary> public TestRunnerAction() { runner = new CSpecTestRunner(); formatter = new ConsoleFormatter(); console = new CSpecConsole(formatter); Commands = new List <ICommand>() { new Commands.RunnerAllCommand() }; }
/// <summary> /// Runs tests specified in the test package, applying /// the supplied filter. /// </summary> /// <param name="package">A TestPackage.</param> /// <param name="filter">A TestFilter (currently ignored)</param> /// <returns>An XmlNode representing the test results.</returns> public ITestEngineResult Run(TestPackage package, ITestEventHandler listener, TestFilter filter) { using (ITestRunner runner = GetRunner()) { ITestEngineResult loadResult = runner.Load(package); return(loadResult.HasErrors ? loadResult : runner.Run(listener, filter)); } }
private int RunTests(TestPackage package, TestFilter filter) { // TODO: We really need options as resolved by engine for most of these DisplayRequestedOptions(); // TODO: Incorporate this in EventCollector? RedirectOutputAsRequested(); var labels = _options.DisplayTestLabels != null ? _options.DisplayTestLabels.ToUpperInvariant() : "ON"; TestEventHandler eventHandler = new TestEventHandler(_outWriter, labels); XmlNode result = null; // Save things that might be messed up by a bad test TextWriter savedOut = Console.Out; TextWriter savedError = Console.Error; DateTime startTime = DateTime.Now; try { using (new ColorConsole(ColorStyle.Output)) using (ITestRunner runner = _engine.GetRunner(package)) { result = runner.Run(eventHandler, filter); } } finally { Console.SetOut(savedOut); Console.SetError(savedError); RestoreOutput(); } //Console.WriteLine(); ResultReporter reporter = new ResultReporter(result, _options); reporter.ReportResults(); // TODO: Inject this? var outputManager = new OutputManager(result, _workDirectory); foreach (var outputSpec in _options.ResultOutputSpecifications) { outputManager.WriteResultFile(outputSpec, startTime); } return(reporter.Summary.ErrorsAndFailures); }
public static XmlNode DoWork(string assemblyName) { var assembly = AssemblyLoadContext.Default.Assemblies.First(x => x.GetName().Name == assemblyName); ITestEngine engine = TestEngineActivator.CreateInstance(); TestPackage package = new TestPackage(assembly.Location); package.Settings[FrameworkPackageSettings.RunOnMainThread] = true; ITestRunner runner = engine.GetRunner(package); return(runner.Run(Listener, TestFilter.Empty)); }
public static void FeatureSetup(TestContext testContext) { LogFeature.testRunner = TestRunnerManager.GetTestRunner(); var featureInfo = new FeatureInfo( new CultureInfo("zh-TW"), "Log", "In Order to 寫入訊息\r\nAs a 程式物件\r\nI Want to 輸出到Dummy物件", ProgrammingLanguage.CSharp, null); LogFeature.testRunner.OnFeatureStart(featureInfo); }
public static void FeatureSetup(TestContext testContext) { CSVFeature.testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); var featureInfo = new TechTalk.SpecFlow.FeatureInfo( new System.Globalization.CultureInfo("en-US"), "CSV", "In order to 解析CSV格式資料\r\nAs a 程式物件\r\nI want to 把CSV資料轉成對應物件", ProgrammingLanguage.CSharp, (string[])null); CSVFeature.testRunner.OnFeatureStart(featureInfo); }
private TestRunResults[] runTests(ITestRunner testRunner, TestRunInfo[] runInfos, Action <AutoTest.TestRunners.Shared.Targeting.Platform, Version, Action <System.Diagnostics.ProcessStartInfo, bool> > processWrapper) { try { return(testRunner.RunTests(runInfos, processWrapper, () => { return _exit; })); } catch (Exception ex) { return(new TestRunResults[] { new TestRunResults("", testRunner.GetType().ToString(), false, TestRunner.Any, new TestResult[] { new TestResult(TestRunner.Any, TestRunStatus.Failed, "AutoTest.Net internal error", ex.ToString()) }) }); } }
public PreparingTestRunner(int threadId, ITestFrameworkReporter reporter, ILogger logger, SettingsWrapper settings, SchedulingAnalyzer schedulingAnalyzer) { _logger = logger; _settings = settings; string threadName = ComputeThreadName(threadId, _settings.MaxNrOfThreads); _threadName = string.IsNullOrEmpty(threadName) ? "" : $"{threadName} "; _threadId = Math.Max(0, threadId); _testDirectory = Utils.GetTempDirectory(); _innerTestRunner = new SequentialTestRunner(_threadName, _threadId, _testDirectory, reporter, _logger, _settings, schedulingAnalyzer); }
public TestEventListener( ITestEngine engine, TestPackage package, ConcurrentQueue <ReportItem> reportItems, string threadName ) { _reportItems = reportItems; Runner = engine.GetRunner(package); _threadName = threadName; }
public virtual void FeatureSetup() { testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); var featureInfo = new FeatureInfo( new CultureInfo("en-US"), "Composite settings can be validated", "In order to fail fast and identify configuration errors early\r\nAs a composite dev" + "eloper\r\nI want to be able to validate configuration and get a description of any" + " errors that occur", ProgrammingLanguage.CSharp, new[] { "SdkSpecs", "Configuration", "Composite" }); testRunner.OnFeatureStart(featureInfo); }
public async Task <IEnumerable <SurvivingMutant> > RunAll( ITestRunner testRunner, string baseTempDirectory, IEventListener eventListener) { var survivingMutants = new List <SurvivingMutant>(); var survivingSyntaxNodes = new HashSet <SyntaxNode>(); var reportedMembers = new HashSet <string>(); var jobsBySourceFile = jobsWithMetadata.GroupBy(x => x.Key.SourceFilePath, x => x).ToArray(); for (var sourceFileIndex = 0; sourceFileIndex < jobsBySourceFile.Length; sourceFileIndex++) { var jobsForSourceFile = jobsBySourceFile[sourceFileIndex]; var sourceFilePath = jobsForSourceFile.Key; eventListener.BeginMutationOfFile( sourceFilePath, Path.GetDirectoryName(config.SolutionFilePath), sourceFileIndex, jobsBySourceFile.Length); foreach (var mutationJobAndMetadata in jobsForSourceFile) { var metadata = mutationJobAndMetadata.Key; var mutationJob = mutationJobAndMetadata.Value; var syntaxNodeAlreadyHadSurvivingMutant = survivingSyntaxNodes.Contains(mutationJob.OriginalNode); if (syntaxNodeAlreadyHadSurvivingMutant) { continue; } if (!reportedMembers.Contains(metadata.MemberName)) { eventListener.MemberMutating(metadata.MemberName); reportedMembers.Add(metadata.MemberName); } eventListener.SyntaxNodeMutating(metadata.SyntaxNodeIndex, metadata.SyntaxNodesTotal); var survivingMutant = await mutationJob.Run(testRunner, baseTempDirectory, eventListener); if (survivingMutant != null) { survivingMutants.Add(survivingMutant); survivingSyntaxNodes.Add(mutationJob.OriginalNode); eventListener.MutantSurvived(survivingMutant); } } eventListener.EndMutationOfFile(sourceFilePath); } return(survivingMutants); }
public void SetUp() { runner = new TestRunner(); test = new Test("fake").Section<TimeoutFixture>(x => { x.WithStep("Go"); }); runner.RunTest(new TestExecutionRequest() { Test = test, TimeoutInSeconds = 1 }); }
public CoverageExplorerViewModel(ICoverageProvider coverageProvider, IEditorContext editorContext, ITestRunner testRunner) { _coverageProvider = coverageProvider; _editorContext = editorContext; _testRunner = testRunner; SearchViewModel = new CodeItemSearchViewModel <CoverageItemViewModel, CoverageItem>(); _coverageProvider.CoverageUpdated += OnCoverageUpdated; _editorContext.SolutionClosing += OnSolutionClosing; _testRunner.TestsFinished += OnTestsFinished; }
public SourceWatcher(IBuildRunner buildRunner, ITestRunner testRunner, IFileSystem fileSystem, IFileWatcherFactory fileWatcherFactory, GilesConfig config) { FileWatchers = new List<FileSystemWatcher>(); this.fileSystem = fileSystem; this.buildRunner = buildRunner; this.fileWatcherFactory = fileWatcherFactory; this.config = config; this.testRunner = testRunner; buildTimer = new Timer { AutoReset = false, Enabled = false, Interval = config.BuildDelay }; config.PropertyChanged += config_PropertyChanged; buildTimer.Elapsed += buildTimer_Elapsed; }
protected virtual void InitializeBindingRegistry(ITestRunner testRunner) { var bindingAssemblies = GetBindingAssemblies(); BuildBindingRegistry(bindingAssemblies); testRunner.OnTestRunStart(); #if !SILVERLIGHT EventHandler domainUnload = delegate { OnTestRunnerEnd(); }; AppDomain.CurrentDomain.DomainUnload += domainUnload; AppDomain.CurrentDomain.ProcessExit += domainUnload; #endif }
public void SetUp() { _project = new Project(Path.GetFullPath("someProject.csproj"), new ProjectDocument(ProjectType.CSharp)); _bus = MockRepository.GenerateMock<IMessageBus>(); _listGenerator = MockRepository.GenerateMock<IGenerateBuildList>(); _cache = MockRepository.GenerateMock<ICache>(); _configuration = MockRepository.GenerateMock<IConfiguration>(); _buildRunner = MockRepository.GenerateMock<IBuildRunner>(); _testRunner = MockRepository.GenerateMock<ITestRunner>(); _consumer = new ProjectChangeConsumer(_bus, _listGenerator, _cache, _configuration, _buildRunner, new ITestRunner[] { _testRunner }); _cache.Stub(c => c.Get<Project>(null)).IgnoreArguments().Return(_project); }
internal ScenarioContext(ScenarioInfo scenarioInfo, ITestRunner testRunner, IObjectContainer parentContainer) { this.objectContainer = parentContainer == null ? new ObjectContainer() : new ObjectContainer(parentContainer); TestRunner = testRunner; Stopwatch = new Stopwatch(); Stopwatch.Start(); CurrentScenarioBlock = ScenarioBlock.None; ScenarioInfo = scenarioInfo; TestStatus = TestStatus.OK; PendingSteps = new List<string>(); MissingSteps = new List<string>(); }
public void SetUp() { _bus = MockRepository.GenerateMock<IMessageBus>(); _testRunner = MockRepository.GenerateMock<ITestRunner>(); _testAssemblyValidator = MockRepository.GenerateMock<IDetermineIfAssemblyShouldBeTested>(); _preProcessor = MockRepository.GenerateMock<IPreProcessTestruns>(); var preProcessors = new IPreProcessTestruns[] { _preProcessor }; _removedTestLocator = MockRepository.GenerateMock<ILocateRemovedTests>(); _cache = MockRepository.GenerateMock<ICache>(); _config = MockRepository.GenerateMock<IConfiguration>(); _cache.Stub(x => x.GetAll<Project>()).Return(new Project[] {}); _consumer = new AssemblyChangeConsumer(new ITestRunner[] { _testRunner }, _bus, _testAssemblyValidator, preProcessors, _removedTestLocator, _cache, _config); _testRunner.Stub(r => r.RunTests(null, null, null)).IgnoreArguments().Return(new TestRunResults[] {}); }
internal HomeViewModel(INavigation navigation, ITestRunner runner) { this.navigation = navigation; this.runner = runner; TestAssemblies = new ObservableCollection<TestAssemblyViewModel>(); OptionsCommand = new DelegateCommand(OptionsExecute); CreditsCommand = new DelegateCommand(CreditsExecute); runEverythingCommand = new DelegateCommand(RunEverythingExecute, () => !isBusy); NavigateToTestAssemblyCommand = new DelegateCommand<object>(async vm => await navigation.NavigateTo(NavigationPage.AssemblyTestList, vm)); StartAssemblyScan(); }
private void ComputeTestRunner(ITestFrameworkReporter reporter, bool isBeingDebugged, string solutionDirectory) { if (_testEnvironment.Options.ParallelTestExecution && !isBeingDebugged) { _runner = new ParallelTestRunner(reporter, _testEnvironment, solutionDirectory); } else { _runner = new PreparingTestRunner(0, solutionDirectory, reporter, _testEnvironment); if (_testEnvironment.Options.ParallelTestExecution && isBeingDebugged) { _testEnvironment.DebugInfo( "Parallel execution is selected in options, but tests are executed sequentially because debugger is attached."); } } }
public void SetUp() { _project = new Project(Path.GetFullPath("someProject.csproj"), new ProjectDocument(ProjectType.CSharp)); _project.Value.SetOutputPath(""); _project.Value.SetAssemblyName("someAssembly.dll"); _bus = MockRepository.GenerateMock<IMessageBus>(); _listGenerator = MockRepository.GenerateMock<IGenerateBuildList>(); _configuration = MockRepository.GenerateMock<IConfiguration>(); _buildRunner = MockRepository.GenerateMock<IBuildRunner>(); _testRunner = MockRepository.GenerateMock<ITestRunner>(); _testAssemblyValidator = MockRepository.GenerateMock<IDetermineIfAssemblyShouldBeTested>(); _optimizer = MockRepository.GenerateMock<IOptimizeBuildConfiguration>(); var runInfo = new RunInfo(_project); runInfo.ShouldBuild(); _optimizer.Stub(o => o.AssembleBuildConfiguration(null)).IgnoreArguments().Return(new RunInfo[] { runInfo }); _consumer = new ProjectChangeConsumer(_bus, _listGenerator, _configuration, _buildRunner, new ITestRunner[] { _testRunner }, _testAssemblyValidator, _optimizer); }
private static bool ExecuteRunner(ITestRunner runner) { bool allTestsPassed = false; try { ResultsSummary summary = new ResultsSummary(); int prevFailedTestCount = Int32.MaxValue; int consecutiveFailureCount = 0; for(int runCount = 1; runCount < MAX_TEST_RUNS; runCount++) { summary = runner.RunTests(summary.FailedTestNames); Console.WriteLine("====== TestWrapper Run Attempt {0} =====", runCount); Console.WriteLine(runner.ToString()); Console.WriteLine(summary); Console.WriteLine("======================="); allTestsPassed = summary.Failed == 0; if (allTestsPassed) { break; } if (summary.Failed < prevFailedTestCount) { prevFailedTestCount = summary.Failed; consecutiveFailureCount = 0; } else if (consecutiveFailureCount < MAX_CONSECUTIVE_FAILURE) { consecutiveFailureCount++; } else { break; } } } catch(Exception e) { Console.WriteLine("Exception occurred running tests:\n {0}", e.ToString()); allTestsPassed = false; } return allTestsPassed; }
/// <inheritdoc /> public void RegisterAutoActivatedExtensions(ITestRunner testRunner) { if (testRunner == null) throw new ArgumentNullException("testRunner"); var context = runtime.RuntimeConditionContext; foreach (var factoryHandle in factoryHandles) { TestRunnerExtensionFactoryTraits traits = factoryHandle.GetTraits(); if (traits.AutoActivationCondition != null) { if (traits.AutoActivationCondition.Evaluate(context)) { ITestRunnerExtensionFactory factory = factoryHandle.GetComponent(); testRunner.RegisterExtension(factory.CreateExtension()); } } } }