Skip to content

Commit 5e891f6

Browse files
committed
dispose test helper on TestCleanup
1 parent be6c276 commit 5e891f6

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

UITests/UITests.Tests.Shared/UITestBase.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ namespace UITests.Tests
2626
{
2727
public abstract class UITestBase
2828
{
29+
private TestSetupHelper helper;
30+
2931
public static TestApplicationInfo WinUICsUWPSampleApp
3032
{
3133
get
@@ -87,7 +89,10 @@ public static TestSetupHelper.TestSetupHelperOptions TestSetupHelperOptions
8789
[TestInitialize]
8890
public async Task TestInitialize()
8991
{
90-
PreTestSetup();
92+
// This will reset the test for each run (as from original WinUI https://github.com/microsoft/microsoft-ui-xaml/blob/master/test/testinfra/MUXTestInfra/Infra/TestHelpers.cs)
93+
// We construct it so it doesn't try to run any tests since we use the AppService Bridge to complete
94+
// our loading.
95+
helper = new TestSetupHelper(new string[] { }, new TestSetupHelper.TestSetupHelperOptions());
9196

9297
#if USING_TAEF
9398
var fullTestName = TestContext.TestName;
@@ -170,6 +175,12 @@ public async Task TestInitialize()
170175
throw new InvalidOperationException("Test host didn't confirm test ready to execute page: " + pageName);
171176
}
172177

178+
[TestCleanup]
179+
public async Task TestCleanup()
180+
{
181+
helper.Dispose();
182+
}
183+
173184
private void CommunicationService_RequestReceived(AppServiceConnection sender, AppServiceRequestReceivedEventArgs args)
174185
{
175186
AppServiceDeferral messageDeferral = args.GetDeferral();
@@ -209,16 +220,5 @@ private void CommunicationService_RequestReceived(AppServiceConnection sender, A
209220
messageDeferral.Complete();
210221
}
211222
}
212-
213-
// This will reset the test for each run (as from original WinUI https://github.com/microsoft/microsoft-ui-xaml/blob/master/test/testinfra/MUXTestInfra/Infra/TestHelpers.cs)
214-
// We construct it so it doesn't try to run any tests since we use the AppService Bridge to complete
215-
// our loading.
216-
private void PreTestSetup()
217-
{
218-
_ = new TestSetupHelper(new string[] { }, new TestSetupHelper.TestSetupHelperOptions()
219-
{
220-
AutomationIdOfSafeItemToClick = null
221-
});
222-
}
223223
}
224224
}

0 commit comments

Comments
 (0)