public static GaugeVersionInfo GetInstalledGaugeVersion(IGaugeProcess gaugeProcess = null) { if (gaugeProcess == null) { gaugeProcess = GaugeProcess.ForVersion(); } gaugeProcess.Start(); var error = gaugeProcess.StandardError.ReadToEnd(); gaugeProcess.WaitForExit(); if (gaugeProcess.ExitCode != 0) { throw new GaugeVersionNotFoundException(error); } var serializer = new DataContractJsonSerializer(typeof(GaugeVersionInfo)); var versionText = SanitizeDeprecationMessage(gaugeProcess.StandardOutput.ReadToEnd()); using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(versionText))) { return((GaugeVersionInfo)serializer.ReadObject(ms)); } }
public static void AssertCompatibility(IGaugeProcess gaugeProcess = null) { var installedGaugeVersion = GetInstalledGaugeVersion(gaugeProcess); if (new GaugeVersion(installedGaugeVersion.version).CompareTo(MinGaugeVersion) >= 0) { return; } var message = $"This plugin works with Gauge {MinGaugeVersion} or above." + $" You have Gauge {installedGaugeVersion.version} installed." + " Please update your Gauge installation.\n" + " Run 'gauge version' from your command prompt for installation information."; throw new GaugeVersionIncompatibleException(message); }
public GaugeRunner(IEnumerable <TestCase> tests, bool isBeingDebugged, bool isParallelRun, IFrameworkHandle frameworkHandle) { _tests = tests.GroupBy(t => t.Source) .SelectMany(spec => spec.OrderBy(t => t.LineNumber)) .ToList(); _pendingTests = new List <TestCase>(_tests); _isBeingDebugged = isBeingDebugged; _frameworkHandle = frameworkHandle; var projectRoot = _tests.First().GetPropertyValue(TestDiscoverer.GaugeProjectRoot, string.Empty); var gaugeCustomBuildPath = _tests.First().GetPropertyValue(TestDiscoverer.GaugeCustomBuildPath, string.Empty); var scenarios = new List <string>(); foreach (var testCase in _tests) { _frameworkHandle.RecordStart(testCase); _frameworkHandle.SendMessage(TestMessageLevel.Informational, $"Executing Test: {testCase}"); scenarios.Add($"\"{testCase.Source}:{testCase.LineNumber}\""); } _gaugeProcess = GaugeProcess.ForExecution(projectRoot, scenarios, gaugeCustomBuildPath, _isBeingDebugged, isParallelRun); _gaugeProcess.OutputDataReceived += OnOutputDataReceived; }