Skip to content
This repository has been archived by the owner on Jan 8, 2019. It is now read-only.

I can't execute BasicReport class C# #129

Open
MedAmineMerzouk opened this issue Jun 18, 2018 · 0 comments
Open

I can't execute BasicReport class C# #129

MedAmineMerzouk opened this issue Jun 18, 2018 · 0 comments

Comments

@MedAmineMerzouk
Copy link

I am working on the test automation of the ERP dynamics ax 7 with selenium. So I record scenarios with task recorder on dynamics ax 365, and to generate the report I used extentreports 2.41.0, for that I created the class BasicReport:

 using NUnit.Framework;
 using RelevantCodes.ExtentReports;
 using System;
 using System.Collections.Generic;
 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";

    extent = new ExtentReports(reportPath, true);

    extent.AddSystemInfo("Host Name", "MININT-F36S5EH")
        .AddSystemInfo("Environment", "QA")
        .AddSystemInfo("User Name", "Mohamed Amine");

    extent.LoadConfig(projectPath + "extent-config.xml");

  }

   [Test]
  public void DemoReportPass()
   {
    test = extent.StartTest("DemoReportPass");
    Assert.IsTrue(true);
    test.Log(LogStatus.Pass, "Assert Pass as condition is True");
  }

[Test]
public void DemoReportFail()
{
    test = extent.StartTest("DemoReportFail");
    Assert.IsTrue(false);
    test.Log(LogStatus.Pass, "Assert Pass as condition is Fail");

}

  [TearDown]
  public void GetResult()
  {
    var status = TestContext.CurrentContext.Result.Outcome.Status;
    var stackTrace = "<pre>" + 
  TestContext.CurrentContext.Result.StackTrace + "</pre>";
    var errorMessage = TestContext.CurrentContext.Result.Message;

    if (status == NUnit.Framework.Interfaces.TestStatus.Failed)

    {
        test.Log(LogStatus.Fail, stackTrace + errorMessage);
    }
    extent.EndTest(test);
}

  [OneTimeTearDown]
  public void EndReport()
  {
    extent.Flush();
    extent.Close();
  }


 }
 }

and when I run the project, this class is ignored. then in the test class above that I want to run, I instantiated the class, but I can't call the methods contained in the class

   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;

  namespace TatAutomationFramework.Web

 {
 [TestClass]
  public sealed class TestFullScenarioBase
 {
StringBuilder sb;


  /// <summary>
  /// Gets the test context. Use the property for setting test transactions 
in the performance tests.
/// </summary>
  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 void SetupData()
  {
    PurchCreateOrder_PurchTable_OrderAccount = "US_TX_008";
    PurchTable_PurchLine_ItemId = "A0002";
    PurchTable_InventoryDimensionsGrid_InventSiteId = "2";
    PurchTable_PurchLine_PurchQtyGrid = 3m;
    PurchTable_PurchLine_PurchPriceGrid = 20m;
    PurchEditLines_PurchParmTable_Num = "3";
  }

   [TestMethod]
  public void TestFullScenario()
  {



    using (var c = this.CreateClientContext())
    {
        using (var c1 = c.Navigate<PurchTable>("purchtablelistpage", 
    Microsoft.Dynamics.TestTools.Dispatcher.MenuItemType.Display))
        {
            PurchTableForm = c1.Form<PurchTable>();
            using (var c2 = c1.Action("SystemDefinedNewButton_Click"))
            {


 Microsoft.Dynamics.TestTools.Dispatcher
.Client.Controls
 .CommandButtonControl.Attach(PurchTableForm,"SystemDefinedNewButton")
 .Click();
                using (var c3 = c2.Attach<PurchCreateOrder>())
                {
                    PurchCreateOrderForm = c3.Form<PurchCreateOrder>();

   PurchCreateOrderForm.PurchTable_OrderAccount
   .SetValue(PurchCreateOrder_PurchTable_OrderAccount);
                    PurchCreateOrderForm.OK.Click();
                }
            }

            PurchTableForm.LineSpec.MarkActiveRow();

   PurchTableForm.PurchLine_ItemId.SetValue(PurchTable_PurchLine_ItemId);

    PurchTableForm
  .InventoryDimensionsGrid_InventSiteId
   .SetValue(PurchTable_InventoryDimensionsGrid_InventSiteId);
            PurchTableForm.PurchLine_PurchQtyGrid
    .SetValue(PurchTable_PurchLine_PurchQtyGrid);
            PurchTableForm.PurchLine_PurchPriceGrid
  .SetValue(PurchTable_PurchLine_PurchPriceGrid);
            Microsoft.Dynamics.TestTools.Dispatcher.Client
  .Controls.CommandButtonControl
  .Attach(PurchTableForm,"SystemDefinedSaveButton").Click();
            PurchTableForm.Purchase.Activate();
            PurchTableForm.ButtonConfirm.Click();
            PurchTableForm.Receive.Activate();
            using (var c4 = c1.Action("buttonUpdatePackingSlip_Click"))
            {
                PurchTableForm.ButtonUpdatePackingSlip.Click();
                using (var c5 = c4.Attach<PurchEditLines>())
                {
                    PurchEditLinesForm = c5.Form<PurchEditLines>();
                    PurchEditLinesForm.GridParmTable.MarkActiveRow();
                    PurchEditLinesForm.PurchParmTable_Num
    .SetValue(PurchEditLines_PurchParmTable_Num);
                    PurchEditLinesForm.OK.Click();
                }
            }
        }
    }
   }

  BasicReport BsRep = new BasicReport();

}

but the html file doesn't generate, and the class doesn't run.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant