diff --git a/src/qest/Commands/GenerateCommand.cs b/src/qest/Commands/GenerateCommand.cs index 442bf0d..74be141 100644 --- a/src/qest/Commands/GenerateCommand.cs +++ b/src/qest/Commands/GenerateCommand.cs @@ -113,7 +113,6 @@ public override async Task ExecuteAsync([NotNull] CommandContext context, [ } await Utils.SafeWriteYamlAsync(folder!, currentTest); - } catch (Exception ex) { diff --git a/src/qest/Commands/RunCommand.cs b/src/qest/Commands/RunCommand.cs index d669ea6..afe6a92 100644 --- a/src/qest/Commands/RunCommand.cs +++ b/src/qest/Commands/RunCommand.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using System.Data.SqlClient; using System.Diagnostics.CodeAnalysis; @@ -7,6 +6,7 @@ using System.Linq; using System.Threading.Tasks; using qest.Models; +using qest.Runners; using Spectre.Console; using Spectre.Console.Cli; namespace qest.Commands @@ -86,24 +86,33 @@ public override async Task ExecuteAsync([NotNull] CommandContext context, [ TestCollection.AddRange(await Utils.SafeReadYamlAsync(item)); } - AnsiConsole.MarkupLine($"[grey]{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}[/] {TestCollection.Count} tests loaded."); + var root = new Tree($"{TestCollection.Count} tests loaded"); TargetSqlConnection = new SqlConnection(settings.ConnectionString); int exitCode = 0; - foreach (var test in TestCollection) - { + await AnsiConsole.Live(root) + .StartAsync(async ctx => + { + foreach (var test in TestCollection) + { + var testNode = root.AddNode($"{test.Name}".EscapeAndAddStyles("bold,blue")); - test.Connection = TargetSqlConnection; - bool pass = await test.RunAsync(); + var runner = new TreeRunner(test, TargetSqlConnection, testNode); + ctx.Refresh(); + + bool pass = await runner.RunAsync(); + ctx.Refresh(); + + if (!pass) + { + exitCode = 1; + break; + } + } + }); - if (!pass) - { - exitCode = 1; - break; - } - } return exitCode; } diff --git a/src/qest/Models/Script.cs b/src/qest/Models/Script.cs index 011855e..4792169 100644 --- a/src/qest/Models/Script.cs +++ b/src/qest/Models/Script.cs @@ -44,4 +44,9 @@ public enum ScriptType Inline, File } + + public class Scripts : List