Skip to content

Commit 6c77e29

Browse files
committed
test: add error message if no allure results exist
1 parent 1398f8a commit 6c77e29

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/Allure.Testing/AllureSampleRunner.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,25 @@ static async Task<Guard<DirectoryInfo>> EnsureSampleResults(
9696
CancellationToken ct
9797
) =>
9898
sample.IsAssertionOnly
99-
? new DirectoryInfo(sample.DefaultResultsPath)
99+
? EnsureExistingAllureResultsDirectory(sample)
100100
: await ProduceSampleResults(sample, input, ct);
101101

102+
static DirectoryInfo EnsureExistingAllureResultsDirectory(AllureSampleRegistryEntry sample)
103+
{
104+
var path = sample.DefaultResultsPath;
105+
var dInfo = new DirectoryInfo(path);
106+
if (!dInfo.Exists || !dInfo.EnumerateFiles().Any())
107+
{
108+
throw new FileNotFoundException(
109+
$"Can't read Allure results of the '{sample.Id}' sample. Please, make sure "
110+
+ $"the sample's been run and the results are available at '{path}'. "
111+
+ "You can use the 'dotnet msbuild -t:Allure_RunTestSamples' command "
112+
+ "to run all samples of the solution/project."
113+
);
114+
}
115+
return dInfo;
116+
}
117+
102118
static async Task<Guard<DirectoryInfo>> ProduceSampleResults(
103119
AllureSampleRegistryEntry sample,
104120
AllureSampleRunInput input,

0 commit comments

Comments
 (0)