【问题标题】:Run MsTest script from within a .Net Step Definition从 .Net 步骤定义中运行 MsTest 脚本
【发布时间】:2014-01-03 15:29:05
【问题描述】:

让我从一些项目开始背景

我将 .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 voidWhenICallTheDataGenerator() 中),但我知道它不正确。

代码用于我的步骤定义:

    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。

提前致谢。

【问题讨论】:

    标签: mbunit


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-01
      • 1970-01-01
      • 2023-02-06
      相关资源
      最近更新 更多