Good evening folks.
This is practically my first test with StoryQ and my first post to a CodePlex forum, so apologies in advance
The test is failing when I do
.ExecuteWithReport();
It passes when I just do:
.Execute();
I've been able to get a simple test to pass with .ExecuteWithReport(); but NOT this parameterized one.
PS: I understand that I'm not allowed underscores in method names but what about variables?
Apendix 1: Stack Trace (for first test)
C:\Data\Websites\MyWeb\MyWeb.Tests.UAT\bin\Release
Story is will check that links work
In order to see that links work
As a non-subscriber
I want to click each link
With scenario
Given I am on the login page => Passed
When I click a link(mw_ContactViaLogin) => Passed
Then I go to the right page => Passed
TestCase 'MyWeb.Tests.UAT.StoryQ.Client.OnLoginPageButNotLoggedIn.AllTheLinksWillWork()'
failed: System.ArgumentNullException : Value cannot be null.
Parameter name: value
at System.Xml.Linq.XAttribute..ctor(XName name, Object value)
at StoryQ.Execution.Rendering.XmlRenderer.<Render>b__0(Result x)
at System.Linq.Enumerable.WhereSelectListIterator
2.MoveNext()
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at System.Xml.Linq.XContainer.AddContentSkipNotify(Object content)
at System.Xml.Linq.XElement..ctor(XName name, Object[] content)
at StoryQ.Execution.Rendering.XmlRenderer.Render(IEnumerable1 results)
at StoryQ.Infrastructure.FragmentBase.<>c__DisplayClass7.<StoryQ.Infrastructure.IStepContainer.Execute>b__5(IRenderer x)
at System.Array.ForEach[T](T[] array, Action`1 action)
at StoryQ.Infrastructure.FragmentBase.StoryQ.Infrastructure.IStepContainer.Execute(IRenderer[] renderers)
at StoryQ.Infrastructure.FragmentBase.ExecuteWithReport(MethodBase currentMethod)
at StoryQ.Infrastructure.FragmentBase.ExecuteWithReport()
C:\Data\Websites\MyWeb\MyWeb.Tests.UAT\StoryQ\Client\OnLoginPageButNotLoggedIn.cs(47,0): at MyWeb.Tests.UAT.StoryQ.Client.OnLoginPageButNotLoggedIn.AllTheLinksWillWork(HyperLink link)
PS: Line 47 of OnLoginPageButNotLoggedIn is the line beginning: new Story("will check that links work")
Apendix 2: The Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StoryQ;
using NUnit.Framework;
using OpenQA.Selenium.IE;
namespace MyWeb.Tests.UAT.StoryQ.Client
{
[TestFixture]
public class OnLoginPageButNotLoggedIn
{
private InternetExplorerDriver _driver;
[TestFixtureSetUp]
public void FixtureSetUp()
{
_driver = new InternetExplorerDriver();
_driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
}
[TestFixtureTearDown]
public void FixtureTearDown()
{
if (_driver != null) _driver.Close();
}
[SetUp]
public void TestSetUp()
{
_driver.Navigate().GoToUrl(Constants.LOGIN_URL);
}
[Test, TestCaseSource(typeof(HyperLink), "LinkArray")]
public void AllTheLinksWillWork(HyperLink link)
{
Console.WriteLine(Environment.CurrentDirectory);
new Story("will check that links work")
.InOrderTo("see that links work")
.AsA("non-subscriber")
.IWant("to click each link")
.WithScenario(link.Description)
.Given(IAmOnTheLoginPage)
.When(IClickALink, link.LinkID)
.Then(IGoToTheRightPage, link)
.ExecuteWithReport();
}
public void IAmOnTheLoginPage()
{
Assert.True(_driver.Url.Contains(Constants.LOGIN_PAGE), "I'm not on the login page");
}
public void IClickALink(string linkID)
{
_driver.FindElementById(linkID).Click();
}
public void IGoToTheRightPage(HyperLink link)
{
Assert.AreEqual(link.PageTitle, _driver.Title, "Title is wrong");
Assert.AreEqual(link.Url, _driver.Url, "Url is wrong");
Assert.IsTrue(_driver.PageSource.Contains(link.SomeContent), "Page does not contains expected: " + link.SomeContent);
}
}
public class HyperLink
{
public string LinkID { get; set; }
public string Description { get; set; }
public bool IsSlow { get; set; }
public string PageTitle { get; set; }
public string Url { get; set; }
public string SomeContent { get; set; }
public HyperLink() { }
public HyperLink(string linkID, string description, bool isSlow, string title, string url, string content)
{
this.LinkID = linkID;
this.Description = Description;
this.IsSlow = isSlow;
this.PageTitle = title;
this.Url = url;
this.SomeContent = content;
}
public override string ToString()
{
return Description;
}
public static List<HyperLink> Links = new List<HyperLink>
{
new HyperLink ("SubscriptionLink", "Subscription Link" , false, Constants.Contact_Title, Constants.CONTACT_URL, Constants.Contact_Content),
new HyperLink ("ForgotPassword" , "Forgot Password Link", false, Constants.Contact_Title, Constants.CONTACT_URL_ForgotPassword, Constants.Contact_Content)
};
public static HyperLink[] LinkArray = Links.ToArray();
}
}