私はVisual Studio C#でセレンでExtentReportsを使って作業しましたが、これはMy
BasicReportクラスです:
using NUnit.Framework;
using RelevantCodes.ExtentReports;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GettingStartedWithLoadTesting
{
[TestFixture]
public class BasicReport
{
public ExtentReports extent;
public ExtentTest test;
[OneTimeSetUp]
public void StartReport()
{
string pth =
System.Reflection.Assembly.GetCallingAssembly().CodeBase;
string actualPath = pth.Substring(0, pth.LastIndexOf("bin"));
string projectPath = new Uri(actualPath).LocalPath;
string reportPath = projectPath + "Reports\MyOwnReport.html";
//string reportPath =
"C:\PerfSDK\SampleProject\PerfSDKSample\Reports\MyOwnReport.html";
Console.WriteLine("repPath: " + reportPath);
extent = new
ExtentReports("C:\PerfSDK\SampleProject\PerfSDKSample\Reports\
reports.html", true);
Console.WriteLine("extent: " + extent);
File.WriteAllText("C:\PerfSDK\SampleProject\PerfSDKSample\Reports\test11.txt", "aaaaaa");
//test = extent.StartTest("DemoReportPass");
//Assert.IsTrue(true);
//test.Log(LogStatus.Pass, "Assert Pass as condition is True");
extent.AddSystemInfo("Host Name", "MININT-F36S5EH")
.AddSystemInfo("Environment", "QA")
.AddSystemInfo("User Name", "Mohamed Amine");
extent.LoadConfig(projectPath + "extent-config.xml");
/*var status = TestContext.CurrentContext.Result.Outcome.Status;
var stackTrace = "
" + TestContext.CurrentContext.Result.StackTrace + "
私のクラステスト:
using System; using GettingStartedWithLoadTesting; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.Collections.ObjectModel; using MS.Dynamics.TestTools.CloudCommonTestUtilities.Authentication; using MS.Dynamics.TestTools.CloudCommonTestUtilities.Enums; using Microsoft.Dynamics.TestTools.Dispatcher.Client; using MS.Dynamics.TestTools.DispatcherProxyLibrary.ApplicationForms; using MS.Dynamics.Performance.Framework.TaskRecorder; using MS.Dynamics.TestTools.CloudCommonTestUtilities; using System.Text; using System.IO; using RelevantCodes.ExtentReports; using System.Collections.Generic; namespace TatAutomationFramework.Web //namespace MS.Dynamics.Performance.Application.TaskRecorder { [TestClass] public sealed class TestFullScenarioBase : BasicReport { StringBuilder sb; ///
/// Gets the test context. Use the property for
setting test transactions in the performance tests.
///public TestContext TestContext { get; set; } [TestCleanup] public void TestCleanup() { Client.Close(); Client.Dispose(); _userContext.Dispose(); } private DispatchedClient Client; private UserContext _userContext; private TimerProvider timerProvider; [TestInitialize] public void TestSetup() { //For multi-user uncomment following lines //if (this.TestContext != null) //{ // timerProvider = new TimerProvider(this.TestContext); //} SetupData(); _userContext = new UserContext(UserManagement.AdminUser); //For multi-user testing use this line //Client = new DispatchedClientHelper().GetClient(); Client = DispatchedClient.DefaultInstance; Client.ForceEditMode = false; Client.Company = WellKnownCompanyID.USMF.ToString(); Client.Open(); } private ClientContext CreateClientContext() { if (timerProvider != null) { return ClientContext.Create(Client, timerProvider.OnBeginTimer, timerProvider.OnEndTimer); } return ClientContext.Create(Client); } private PurchTable PurchTableForm; private PurchCreateOrder PurchCreateOrderForm; private string PurchCreateOrder_PurchTable_OrderAccount; private string PurchTable_PurchLine_ItemId; private string PurchTable_InventoryDimensionsGrid_InventSiteId; private decimal PurchTable_PurchLine_PurchQtyGrid; private decimal PurchTable_PurchLine_PurchPriceGrid; private PurchEditLines PurchEditLinesForm; private string PurchEditLines_PurchParmTable_Num; private decimal PurchTable_PurchLine_LineAmountGrid; private decimal result_expected; private string message; List}
BasicReportオブジェクトをインスタンス化すると、次のエラーメッセージが表示されます。
Test Name: TestFullScenario Test FullName: TatAutomationFramework.Web.TestFullScenarioBase.TestFullScenario Test Source: C:PerfSDKSampleProjectPerfSDKSampleGeneratedTestFullScenarioBase.cs : line 96 Test Outcome: Failed Test Duration: 0:00:25.5330802 Result StackTrace: at NUnit.Framework.TestContext.ResultAdapter.get_Outcome() at GettingStartedWithLoadTesting.BasicReport.StartReport() in C:PerfSDKSampleProjectPerfSDKSampleBasicReport.cs:line 45 at TatAutomationFramework.Web.TestFullScenarioBase.TestFullScenario() in C:PerfSDKSampleProjectPerfSDKSampleGeneratedTestFullScenarioBase.cs:line 107 Result Message: Test method TatAutomationFramework.Web.TestFullScenarioBase.TestFullScenario threw exception: System.NullReferenceException: Object reference not set to an instance of an object.
ベストアンサー
申し訳ありませんが、適切な答えはありません