Skip to content

Instantly share code, notes, and snippets.

@mattwcole
Created December 12, 2019 21:13
Show Gist options
  • Save mattwcole/180e970883995f45c534485f8217be49 to your computer and use it in GitHub Desktop.
Save mattwcole/180e970883995f45c534485f8217be49 to your computer and use it in GitHub Desktop.
using System;
using System.Threading.Tasks;
using Xunit;
namespace XunitParallel
{
public abstract class GasTests
{
private readonly WebDriver _driver;
protected GasTests(WebDriver driver)
{
_driver = driver;
}
[Fact]
public Task GasTest1()
{
return Task.Delay(5000);
}
[Fact]
public Task GasTest2()
{
return Task.Delay(5000);
}
}
public abstract class ElecTests
{
private readonly WebDriver _driver;
protected ElecTests(WebDriver driver)
{
_driver = driver;
}
[Fact]
public Task ElecTest1()
{
return Task.Delay(5000);
}
[Fact]
public Task ElecTest2()
{
return Task.Delay(5000);
}
}
[Collection("Chrome")]
public class ChromeGasTests : GasTests
{
public ChromeGasTests(ChromeFixture fixture) : base(fixture.Driver)
{
}
}
[Collection("Chrome")]
public class ChromeElecTests : GasTests
{
public ChromeElecTests(ChromeFixture fixture) : base(fixture.Driver)
{
}
}
[Collection("Firefox")]
public class FirefoxGasTests : GasTests
{
public FirefoxGasTests(FirefoxFixture fixture) : base(fixture.Driver)
{
}
}
[Collection("Firefox")]
public class FirefoxElecTests : GasTests
{
public FirefoxElecTests(FirefoxFixture fixture) : base(fixture.Driver)
{
}
}
[CollectionDefinition("Chrome")]
public class ChromeCollection : ICollectionFixture<ChromeFixture>
{
}
[CollectionDefinition("Firefox")]
public class FirefoxCollection : ICollectionFixture<FirefoxFixture>
{
}
public class ChromeFixture : IDisposable
{
public ChromeFixture()
{
Driver = new ChromeWebDriver();
}
public ChromeWebDriver Driver { get; }
public void Dispose()
{
Driver.Dispose();
}
}
public class FirefoxFixture : IDisposable
{
public FirefoxFixture()
{
Driver = new FirefoxWebDriver();
}
public FirefoxWebDriver Driver { get; }
public void Dispose()
{
Driver.Dispose();
}
}
public abstract class WebDriver : IDisposable
{
public void Dispose()
{
}
}
public class ChromeWebDriver : WebDriver
{
}
public class FirefoxWebDriver : WebDriver
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment