Skip to content

Instantly share code, notes, and snippets.

@davybrion
Created September 15, 2012 16:26
Show Gist options
  • Save davybrion/3728675 to your computer and use it in GitHub Desktop.
Save davybrion/3728675 to your computer and use it in GitHub Desktop.
code snippets for "Using Generic TestFixtures To Run Tests In Multiple Browsers With WatiN" post
public abstract class ViewTest<TBrowser> where TBrowser : Browser, new()
{
[TestFixtureSetUp]
public void FixtureSetUp()
{
Browser = new TBrowser();
Browser.GoTo(RootUrl);
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
if (Browser != null)
{
Browser.Dispose();
}
}
[SetUp]
public void SetUp()
{
DoSetUp();
}
protected TBrowser Browser { get; private set; }
protected string RootUrl { get { return ConfigurationManager.AppSettings["RootUrl"]; } }
protected virtual void DoSetUp() { }
}
[TestFixture(typeof(IE))]
[TestFixture(typeof(FireFox))]
public class ListCustomersTests<TBrowser> : ViewTest<TBrowser> where TBrowser : Browser, new()
{
protected override void DoSetUp()
{
Browser.GoTo(RootUrl + "Customers");
}
[Test]
public void ShowsErrorMessageWhenClickingProceedWithoutSelectingAnItemFromGrid()
{
var proceedButton = Browser.Button(button => button.Value == "Proceed");
Assert.IsFalse(Browser.Para("selection_required").Exists);
proceedButton.Click();
Assert.That(Browser.Para("selection_required").Exists);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment