Skip to content

Commit

Permalink
fix(net462): support net462
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Nov 22, 2024
1 parent 8cd88de commit e3c8e56
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Playwright.Xunit/Playwright.Xunit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
and fixtures to enable using it within xUnit.
</Description>
<PackageIcon>icon.png</PackageIcon>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RunWithWarnings>true</RunWithWarnings>
<RootNamespace>Microsoft.Playwright.Xunit</RootNamespace>
Expand Down
22 changes: 16 additions & 6 deletions src/Playwright.Xunit/WorkerAwareTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

namespace Microsoft.Playwright.Xunit;

public class WorkerAwareTest : ExceptionCapturer, IAsyncLifetime
public class WorkerAwareTest : ExceptionCapturer
{
private static readonly ConcurrentStack<Worker> _allWorkers = new();
private Worker? _currentWorker = null!;
private Worker _currentWorker = null!;

internal class Worker
{
Expand Down Expand Up @@ -107,16 +107,26 @@ public interface IWorkerService
/// Note: There is no way of getting the test status in xUnit in the dispose method.
/// For more information, see: https://stackoverflow.com/questions/28895448/current-test-status-in-xunit-net
/// </summary>
public class ExceptionCapturer
public class ExceptionCapturer: IAsyncLifetime
{
protected static bool TestOk { get; private set; } = true;
protected bool TestOk { get; private set; } = true;

[ModuleInitializer]
public static void Setup()
public ExceptionCapturer()
{
AppDomain.CurrentDomain.FirstChanceException += (_, e) =>
{
TestOk = false;
};
}

public Task InitializeAsync()
{
TestOk = true;
return Task.CompletedTask;
}

public Task DisposeAsync()
{
return Task.CompletedTask;
}
}

0 comments on commit e3c8e56

Please sign in to comment.