I’m a tester working with automation and recently looking into webdriver and I get the idea with pageObjects and how to run tests with Nunit for example.
My problem is that I don’t want to run tests in a predefined order. The GUI-automation solution we currently have uses ModelBasedTesting tool GraphWalker to generate the testsequence at execution and I would like to continue with that approach.
It works like this in short: A graph contains action- and verificationsteps and some logic to determine how to “walk the graph”. Each step represent a method to be executed in webdriver.
I could of course make a lot of methods and call them one by one, but then I would not have the nice support of a testing framework like Nunit or the structure of PageObjects.
What I (think) I would like is:
[TestFixture]
public abstract class LoginTest : TestFixtureBase
{
[Test]
public void e_test1()
{
loginPage = PageBase.GetInstance<Login>(driver, "Title");
accountHome = loginPage.MainLogin(username, password);
Assert.IsTrue(accountHome.UserLoggedIn(),"fail");
}
[Test]
public void v_test1()
{
loginPage = accountHome.LogOut();
Assert.IsTrue(loginPage.UserLoggedOut(), "Fail");
}
.
.
.
[Test]
public void e_testN()
{
//Do something
}
And then when i run the graph it gives me “e_test2” as a first step and the magic code runs e_test2(). Next step is “v_test1” so that test is executed.
Anyone knows how to do this?
Update:
I’ve tried the TestCaseSource attribute and got it working, but only when it runs the graph prior the test and returns the complete sequence. I’m looking for a way to execute one step at the time “online”.
This works:
[Test, TestCaseSource("RunModel")]
public void LoginAndOut(string method)
{
object obj = this.GetType().InvokeMember(method, BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public, null, this, null);
}
public string[] RunModel()
{
List<string> methods = new List<string>();
while (Model.graphWalker.HasNextStep())
{
methods.Add(Model.graphWalker.GetNextStep().ToString());
}
return methods.ToArray();
}
But I would like to accomplish something like:
while (Model.graphWalker.HasNextStep())
{ //Get next method from GraphWalker Soap-service.
nextMethodToRun = Model.graphWalker.GetNextStep().ToString());
//handle Method result, if ok continue.
}
Gave up on NUnit and found the solution with Gallio/MbUtnit and DynamicTestFactory.
works just as intended.