Skip to content

Commit 6bab276

Browse files
committed
refactor: enhance error messages in TestCaseValidator and update RunCommand output format
1 parent c3c6c4d commit 6bab276

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/testr.Cli/Commands/RunCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ CancellationToken cancellationToken
165165
.WithDomain(domain)
166166
.WithVariables(VariablesHelper.CreateVariables(_variables.Values));
167167

168-
ConsoleHelper.WriteLineYellow($"Running Test Case: {testCase.Id}");
168+
ConsoleHelper.WriteLineYellow($"Running Test Case Id '{testCase.Id}': {testCase.Title}");
169169

170170
// Validate the Test Case definition
171171
var testCaseValidator = new TestCaseValidator(testCase);

src/testr.Cli/Domain/TestCaseParser.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ internal async Task<TestCase> ToTestCaseAsync(CancellationToken cancellationToke
4141
};
4242
}
4343

44-
private IEnumerable<TestStep> GetTestSteps(string markdownContent)
45-
{
46-
var parser = new MarkdownTableParser(markdownContent);
47-
return parser.ParseTestSteps();
48-
}
49-
5044
private (string TestCaseId, string TestCaseTitle) GetTestCaseIdAndTitle(string[] lines)
5145
{
5246
// we are just reading the first line
@@ -72,6 +66,12 @@ private IEnumerable<TestStep> GetTestSteps(string markdownContent)
7266
return splittedItems[1].Trim();
7367
}
7468

69+
private IEnumerable<TestStep> GetTestSteps(string markdownContent)
70+
{
71+
var parser = new MarkdownTableParser(markdownContent);
72+
return parser.ParseTestSteps();
73+
}
74+
7575
private string? GetLinkedFile(string file, string? link)
7676
{
7777
if (string.IsNullOrWhiteSpace(link)) return null;

src/testr.Cli/Domain/TestCaseValidator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public TestCaseValidationResult Validate()
2323
};
2424
if (!allowedTypes.Contains(_testCase.Type))
2525
{
26-
result.AddError("Type", "Type must be 'Definition' or 'Run'.");
26+
result.AddError("Type", $"Type must be '{Constants.TestCaseType.Definition}' or '{Constants.TestCaseType.Run}'.");
2727
}
2828

2929
// check property Status
@@ -34,7 +34,7 @@ public TestCaseValidationResult Validate()
3434
};
3535
if (!allowedStatus.Contains(_testCase.Status))
3636
{
37-
result.AddError("Status", "Status must be either 'Passed', 'Failed' or 'Unknown'.");
37+
result.AddError("Status", $"Status must be either '{Constants.TestCaseStatus.Passed}', '{Constants.TestCaseStatus.Failed}' or '{Constants.TestCaseStatus.Unknown}'.");
3838
}
3939

4040
// check property Link if contains link should be a valid markdown link pointing to a file

0 commit comments

Comments
 (0)