anshooarora / extentreports-csharp

Community version of Extent API for .NET has moved to https://github.com/extent-framework/
http://extentreports.com/
Other
47 stars 43 forks source link

Trying to use CreateTest Method in ExtentTest class, getting null point exception. #125

Open bhnr opened 6 years ago

bhnr commented 6 years ago

Error: Test method Reports.CodedUITest2.SampleExtentReports threw exception: System.NullReferenceException: Object reference not set to an instance of an object.

Problem in the statement: extenttest = extentreport.CreateTest("HariExtentReports");

Issue in the CreateTest method.

Here is the code snippet: using System; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Windows.Input; using System.Windows.Forms; using System.Drawing; using Microsoft.VisualStudio.TestTools.UITesting; using Microsoft.VisualStudio.TestTools.UITesting.HtmlControls; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UITest.Extension; using Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard; using AventStack.ExtentReports;

using System.Configuration;

namespace Reports { ///

/// Summary description for CodedUITest2 /// [CodedUITest] public class CodedUITest2 { public CodedUITest2() { } public static ExtentReports extentreport; public static ExtentTest extenttest;

    [TestMethod]
    public void SampleExtentReports()
    {

        string dateForFileName = DateTime.Now.Date.Month + "_" + DateTime.Now.Date.Day + "_" + DateTime.Now.Date.Year;
        string path = ConfigurationManager.AppSettings["path"].ToString() + dateForFileName + ".html";

        //extenttest = extentreport.CreateTest("ExtentReports");

    extenttest = extentreport.CreateTest("HariExtentReports");

        BrowserWindow.CurrentBrowser = "ie"; //ie, fireofx
        BrowserWindow math = BrowserWindow.Launch("www.math.com");