Question

let me start with some project background:

I'm using .Net with Specflow and MsTest.

The application I'm working on tracks a customer complaint through numerical stages. So far I've been using Specflow to automation the QA test cases through these stages.

A colleague has given me scripts that input the data via the back end so I can skip the first few common stages. It works when I am manually in the .Net script, right click and Run Tests using MsTest. I've now named this my Data Generator script.

Code for Data Generator script:

namespace Application.IntegrationTests
{
    [TestClass]
    public class CreateComplaintFeatureProxy
    {

        private readonly CreateComplaintFeature _ = new CreateComplaintFeature();

        public TestContext TestContext { get; set; }

        [TestMethod]
        public void CreatesComplaintUptoStage5()
        {
            _.ExecuteTest(m => m.CreatesComplaintUptoStage5(), TestContext);
        }

    }
}

I want to be able to call this script using MsTest via a common Step Definition. I've been experimenting with the below code (inside public void WhenICallTheDataGenerator()) but I know it is not correct.

Code for my Step Definition:

    namespace QaAutomation.WpfHelpers
    {
        public class DataGenerator
        {
            [When(@"I call the data generator")]
            public void WhenICallTheDataGenerator()
            {
                TestLauncher launcher = new TestLauncher();
                TestLauncherResult result = Project.IntegrationTests.CreateComplaintFeatureProxy.Run();
            }
        }
    }

How can I run the 'CreateComplaintFeatureProxy' class using MsTest from within my Step Definition?

Note that both; MbUnit and Gallio are referenced in the project.

Thanks in advance.

No correct solution

OTHER TIPS

This was the code that worked for me in my Step Definition:

namespace ApplicationUnderTest.AutomationTests.WpfHelpers
{
    [Binding]
    [TestClass]
    public class DataGenerator
    {
        [TestMethod]
        [When(@"I create complaint feature proxy")]
        public void WhenICreateComplaintFeatureProxy()
        {
            ApplicationUnderTest.IntegrationTests.CreateComplaintFeatureProxy m = new CreateComplaintFeatureProxy();
            m.CreatesComplaintUptoStage5();
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top