从.Net步骤定义中运行MsTest脚本

时间:2014-01-03 15:29:06

标签: mbunit

让我先介绍一些项目背景

我正在使用.Net与Specflow和MsTest。

我正在处理的应用程序通过数字阶段跟踪客户投诉。到目前为止,我一直在使用Specflow通过这些阶段自动化QA测试用例。

一位同事给了我通过后端输入数据的脚本,所以我可以跳过前几个常见阶段。当我在.Net脚本中手动操作,右键单击并使用MsTest运行测试时,它可以正常工作。我现在将其命名为我的数据生成器脚本。

数据生成器脚本的

代码

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);
        }

    }
}

我希望能够通过常见的步骤定义使用MsTest调用此脚本。我一直在尝试使用下面的代码(在public void void WhereAallTheDataGenerator()中),但我知道它不正确。

我的步骤定义的

代码

    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();
            }
        }
    }

如何在步骤定义中使用MsTest运行'CreateComplaintFeatureProxy'类?

注意两者;项目中引用了MbUnit和Gallio。

提前致谢。

1 个答案:

答案 0 :(得分:0)

这是在我的步骤定义中为我工作的代码:

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();
        }
    }
}