代码之家  ›  专栏  ›  技术社区  ›  Tree55Topz

切换应用程序。运行时C的配置设置#

  •  0
  • Tree55Topz  · 技术社区  · 7 年前

    <leanft></leanft> 在应用程序中进行配置。配置文件。当我通过命令行启动这些测试时,如何在运行时指定不同的配置?谢谢

    1 回复  |  直到 7 年前
        1
  •  1
  •   Adelin    7 年前

    可以在运行时使用 SDK Report 命名空间。

    下面是一个使用NUnit 3的示例,展示了如何实现这一点

    using NUnit.Framework;
    using HP.LFT.SDK;
    using HP.LFT.Report;
    using System;
    
    namespace LeanFtTestProject
    {
        [TestFixture]
        public class LeanFtTest
        {
            [OneTimeSetUp]
            public void TestFixtureSetUp()
            {
                // Initialize the SDK
                SDK.Init(new SdkConfiguration()
                {
                    AutoLaunch = true,
                    ConnectTimeoutSeconds = 20,
                    Mode = SDKMode.Replay,
                    ResponseTimeoutSeconds = 20,
                    ServerAddress = new Uri("ws://127.0.0.1:5095") // local or remote, decide at runtime
                });
    
                // Initialize the Reporter (if you want to use it, ofc)
                Reporter.Init(new ReportConfiguration()
                {
                    Title = "The Report title",
                    Description = "The report description",
                    ReportFolder = "RunResults",
                    IsOverrideExisting = true,
                    TargetDirectory = "", // which means the current parent directory 
                    ReportLevel = ReportLevel.All,
                    SnapshotsLevel = CaptureLevel.All
                });
    
            }
    
            [SetUp]
            public void SetUp()
            {
                // Before each test
            }
    
            [Test]
            public void Test()
            {
                Reporter.ReportEvent("Doing something", "Description");
            }
    
            [TearDown]
            public void TearDown()
            {
                // Clean up after each test
            }
    
            [OneTimeTearDown]
            public void TestFixtureTearDown()
            {
                // If you used the reporter, invoke this at the end of the tests
                Reporter.GenerateReport();
    
                // And perform this cleanup as the last leanft step
                SDK.Cleanup();
            }
        }
    }