private void InitializeLogger(IRunContext runContext, IFrameworkHandle frameworkHandle) { if (_logger == null) { var settingsProvider = runContext.RunSettings.GetSettings(TestsConstants.SettingsName) as SettingsProvider; _logger = new LogMessenger(frameworkHandle, settingsProvider); if (settingsProvider != null) { // get TestSessionTimeout from runsettings var xml = new XmlDocument(); xml.LoadXml(runContext.RunSettings.SettingsXml); var timeout = xml.SelectSingleNode("RunSettings//RunConfiguration//TestSessionTimeout"); if (timeout != null && timeout.NodeType == XmlNodeType.Element) { int.TryParse(timeout.InnerText, out _testSessionTimeout); } _settings = settingsProvider.Settings; _logger.LogMessage( "Getting ready to run tests...", Settings.LoggingLevel.Detailed); _logger.LogMessage( "Settings parsed", Settings.LoggingLevel.Verbose); } else { _logger.LogMessage( "Getting ready to run tests...", Settings.LoggingLevel.Detailed); _logger.LogMessage( "No settings for nanoFramework adapter", Settings.LoggingLevel.Verbose); } } }
/// <inheritdoc/> public void DiscoverTests(IEnumerable <string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink) { _testCases = new List <TestCase>(); var settingsProvider = discoveryContext.RunSettings.GetSettings(TestsConstants.SettingsName) as SettingsProvider; _logger = new LogMessenger( logger, settingsProvider); if (settingsProvider != null) { _logger.LogMessage( "Getting ready to discover tests...", Settings.LoggingLevel.Detailed); _logger.LogMessage( "Settings parsed", Settings.LoggingLevel.Verbose); } else { _logger.LogMessage( "Getting ready to discover tests...", Settings.LoggingLevel.Detailed); _logger.LogMessage( "No settings for nanoFramework adapter", Settings.LoggingLevel.Verbose); } foreach (var source in sources) { _logger.LogMessage( $" New file processed: {source}", Settings.LoggingLevel.Detailed); if (!File.Exists(source)) { _logger.LogMessage( $" File doesn't exist: {source}", Settings.LoggingLevel.Detailed); continue; } var cases = FindTestCases(source); if (cases.Count > 0) { _logger.LogMessage( $" Adding {cases.Count} new tests", Settings.LoggingLevel.Detailed); _testCases.AddRange(cases); } } foreach (var testCase in _testCases) { discoverySink.SendTestCase(testCase); } _logger.LogMessage( "Finished adding files", Settings.LoggingLevel.Detailed); }