Created
September 15, 2012 16:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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