SDK
名前空間またはReport
名前空間を使用して、実行時に任意の構成を変更できます。ここで
は、あなたが、私はそれを切り替えることができないだろうのようにそれは難しい、しかし、コード化されることになるようにこれは思えるこの
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();
}
}
}
を達成する方法を示すNUnitの3を使用した例です。私はローカルで実行されるデフォルトのApp.Config設定を持っています。いくつかのコマンドライン引数で切り替えることができる追加の設定を定義したいと思います。私はこのアプローチでそれを行うことはできますか? – Tree55Topz
間違いなく。それは 'LeanFT'でもなく、' C# 'です - あなたは' serverToUse'という名前の変数を定義し、それを 'SdkConfiguration'コンストラクタの' ServerAddress'プロパティ(AKA 'new Uri(serverToUse)')で使用します。 – Adelin
コマンドライン引数を解析するには、[この回答](https://stackoverflow.com/questions/491595/best-way-to-parse-command-line-arguments-in-c)から選択してください。 – Adelin