Skip to content

Commit f838465

Browse files
Don't throw during cleanup if test class directory does not exist (Azure#34909)
1 parent 84355c5 commit f838465

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sdk/core/Azure.Core.TestFramework/src/RecordedTestBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,12 @@ public void TearDownRecordedTestClass()
352352
// Clean up unused test files
353353
if (Mode == RecordedTestMode.Record)
354354
{
355+
var testClassDirectory = new DirectoryInfo(GetSessionFileDirectory());
356+
if (!testClassDirectory.Exists)
357+
{
358+
return;
359+
}
360+
355361
var knownMethods = new HashSet<string>();
356362

357363
// Management tests record in ctor
@@ -373,7 +379,7 @@ public void TearDownRecordedTestClass()
373379
knownMethods.Add(method.Name);
374380
}
375381

376-
foreach (var fileInfo in new DirectoryInfo(GetSessionFileDirectory()).EnumerateFiles())
382+
foreach (var fileInfo in testClassDirectory.EnumerateFiles())
377383
{
378384
bool used = knownMethods.Any(knownMethod => fileInfo.Name.StartsWith(knownMethod, StringComparison.CurrentCulture));
379385

0 commit comments

Comments
 (0)