Beispiel #1
0
        static void Main(string[] args)
        {
            var extent = new ExtentReports("Extent.Net.html");

            var test = extent.StartTest("First", "Random desc");
            test.Log(LogStatus.Info, "Some Details");
            test
                .AssignCategory("Cat", "Cat", "Cat")
                .AssignAuthor("Anshoo", "Anshoo");
            extent.EndTest(test);

            test = extent.StartTest("Second", "Random desc");
            var child = extent.StartTest("Child", "Desc");
            child.Log(LogStatus.Warning, "Warning");
            child.AssignCategory("Regression", "Extent");
            test.AppendChild(child);
            extent.EndTest(test);

            test = extent.StartTest("Third", "Random desc");
            test.Log(LogStatus.Error, "Some Details");
            extent.EndTest(test);

            extent.Flush();
        }
Beispiel #2
0
 public void TestCleanUp()
 {
     #region Code Injection
     for (int i = 0; i < customLogCollection.Count; i++)
     {
         if (customLogCollection[i] != null)
         {
             customReport.EndTest(customLogCollection[i]);
             customReport.Flush();
             customLogCollection[i] = null;
         }
     }
     customLogCollection.Clear();
     WiniumDriver.WiniumFinalise();
     driver.Dispose();
     ClearBrowser();
     #endregion
 }
Beispiel #3
0
        static void Main(string[] args)
        {
            var extent = new ExtentReports("Extent.Net.html", false);

            extent.AssignProject("Extent");
            //extent.X();

            string json = "{" +
                          "\"id\": 1," +
                          "\"name\": \"A green door\"," +
                          "\"price\": 12.50," +
                          "\"tags\": [\"home\", \"green\"]" +
                          "}";

            string message = "This test shows how a category is displayed. Assigning a category also " +
                             "enables the Categories view.";
            ExtentTest test = extent.StartTest("CategoryTest", message);

            test.AssignCategory("ExtentAPI", "Category");
            test.Log(LogStatus.Pass, "中文");
            test.Log(LogStatus.Info, "<pre>" + json + "</pre>");
            extent.EndTest(test);

            message = "This test shows an example of an author assigned.";
            test    = extent.StartTest("AuthorTest", message);
            test.AssignAuthor("Anshoo");
            test.Log(LogStatus.Fail, "An author was added");
            extent.EndTest(test);

            message = "This test shows an example of an author assigned.";
            test    = extent.StartTest("AuthorTest", message);
            test.AssignAuthor("Anshoo");
            test.Log(LogStatus.Pass, "An author was added 2");
            extent.EndTest(test);

            Exception nullPointerEx = new NullReferenceException("A NullReferenceException occured.");

            message = "This test shows an example of how exceptions are displayed. " +
                      "Logging an exception also creates the Exceptions view.";
            test = extent.StartTest("ExceptionTest", message);
            test.AssignCategory("ExtentAPI", "IntentionalException");
            test.Log(LogStatus.Fail, nullPointerEx);
            extent.EndTest(test);

            message = "HTML can be embedded anywhere in the report to create meaningful.Logs and messages.";
            test    = extent.StartTest("HTMLTagsTest", message);
            string labelMessage = "Labels can be created using: " +
                                  "<span class='success label'>Success</span> " +
                                  "<span class='fail label'>Fail</span> " +
                                  "<span class='warning label'>Warning</span> " +
                                  "<span class='info label'>Info</span> " +
                                  "<span class='Skip label'>Skip</span>";

            test.Log(LogStatus.Pass, labelMessage);
            labelMessage = "<pre>" +
                           "&lt;span class='success label'&gt;Success&lt;/span&gt; <br />" +
                           "&lt;span class='fail label'&gt;Fail&lt;/span&gt; <br />" +
                           "&lt;span class='warning label'&gt;Warning&lt;/span&gt; <br />" +
                           "&lt;span class='info label'&gt;Info&lt;/span&gt; <br />" +
                           "&lt;span class='Skip label'&gt;Skip&lt;/span&gt;" +
                           "</pre>";
            test.Log(LogStatus.Pass, labelMessage);
            test.Log(LogStatus.Pass, "Link <a href='http://extentreports.relevantcodes.com/'>Linky</a>");
            test.Log(LogStatus.Pass, "<pre>&lt;a href='http://extentreports.relevantcodes.com/'&gt;Linky&lt;/a&gt;</pre>");
            extent.EndTest(test);

            test = extent.StartTest("NodesTest");
            ExtentTest child1 = extent.StartTest("Child Node Level 1").AssignCategory("Node");

            child1.Log(LogStatus.Info, "Info");
            ExtentTest childLevel2 = extent.StartTest("Child Node Level 2").AssignCategory("Node");;

            childLevel2.Log(LogStatus.Error, "Error");
            ExtentTest childLevel3 = extent.StartTest("Child Node Level 3").AssignCategory("Node");;

            childLevel3.Log(LogStatus.Warning, "Warning");
            ExtentTest childLevel4 = extent.StartTest("Child Node Level 4").AssignCategory("Node");;

            childLevel4.Log(LogStatus.Skip, "Skip");
            ExtentTest childLevel5 = extent.StartTest("Child Node Level 5").AssignCategory("Node");;

            childLevel5.Log(LogStatus.Pass, "Pass");
            test.AppendChild(child1);
            test.AppendChild(childLevel2);
            test.AppendChild(childLevel3);
            test.AppendChild(childLevel4);
            test.AppendChild(childLevel5);
            childLevel2 = extent.StartTest("Child Node Level 2").AssignCategory("Node");;
            childLevel2.Log(LogStatus.Error, "Error");
            test.AppendChild(childLevel2);
            extent.EndTest(test);

            test = extent.StartTest("MediaTest");
            test.Log(LogStatus.Info, test.AddScreenCapture("./1.png"));
            test.Log(LogStatus.Info, test.AddScreenCapture("2.png"));
            test.Log(LogStatus.Info, test.AddBase64ScreenCapture(" data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMoAAAAYCAYAAAC7k2KMAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAAi4SURBVHhe7ZstsBRHFIWfQCAQCAQCgUAgEAgEAoGIQCAQCAQCEYFAICIiEFQhIhAIBCICgUAgEAhEREREBAIRgYhARCAQERERiJfzDXPnnbnbMz09uyJU7an66u1O3+7t6b63/2beweHh4Z49eyoUL+7Zs2fM0YeDg4eCD1P8Lf4Qb8UNL6TP/1HkPCU+Znsvp4TbVoiyn9q1v8TJXGYJ6XmfB+6I3Ca3S/mWIPk9/FqyyWBnec6m73N07TCFdEncEz+L9+JP8UY8ERt9W0O6IB4I6kd7fxFR5g/iTCkfSFN+Rxm0GfV7Le6KuXKafMTynRCPxO/iX5Ht4Y5nqAVKhkY5b/lbnXmwjzKmcNsKUTY373me5zJLYGd5SoHCYDHZWXNI+R6+L9k50k4DRTolXvU2c+Cc1YCRjovHAqfOZTj/iHsTZbT4Hb9DMG8MfFKTj/R5LvK9vz7HZKDQUDhNQOMScThK2ADXjhUqynU6tcTLbB91mMJtRbXsPs8V4R143cssIdUCBX4p5a0h5Q6pBp3EPYU9g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EP1gRKXpa8sTS/h1qg5OVSMY+n57QSEoOCL4GmIIDq7z99XXL6pncKZh/2eKW9rbfxEpi9Sm2xa/9jBn40lG8/VA0UkFgn+pFxt0aVdl3RjjVlr0HKHd4cKCBx5OlLhDjq9XuYDRSQ+MezsC/m8fScNofEbMASi3U4fUl9CUxGcN6Bqr6S40gsFzmIYDZhFqE8BlGemfAvx5P3K80FCjMHIzzlEGiT79VJu/I/2oFgHJ7Kd/b+Zc+ePWWKF/fs2eMcHvwHRtCmdoL3r8UAAAAASUVORK5CYII="));
            extent.EndTest(test);

            test = extent.StartTest("SkippedTest").AssignCategory("ExtentAPI");;
            test.Log(LogStatus.Skip, "Skip");
            test.Log(LogStatus.Pass, "Pass");
            test.Log(LogStatus.Info, "Info");
            extent.EndTest(test);

            extent.AddTestRunnerOutput("You can send all.Logs from your TestRunner (such as JUnit, TestNG etc) to Extent by using:");
            extent.AddTestRunnerOutput("<pre>for (string s : Reporter.getOutput()) { <br />    extent.setTestRunnerOutput(s); <br />}</pre>");

            extent.Flush();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var extent = new ExtentReports("Extent.Net.html");

            extent.ConfigurationFromFile(@"C:\Users\Anshoo\git\extentreports\dotnet\RelevantCodes.ExtentReports\RelevantCodes.ExtentReports\bin\Debug\config.xml");

            extent.AddTestRunnerOutput("You can send all logs from your TestRunner (such as NUnit, Gallio, MSTest etc) to Extent by using:");
            extent.AddTestRunnerOutput("<pre>for (string s : Reporter.GetOutput()) { <br />    extent.AddTestRunnerOutput(s); <br />}</pre>");
            extent.AddTestRunnerOutput("Visit <a href='https://github.com/anshooarora/extentreports/blob/master/java/extentreports/src/test/java/com/relevantcodes/extentreports/testngexamples/ExtentReporterNG.java'>this link</a> for more info.");

            extent.AddSystemInfo("Machine Name", "Anshoo");
            extent.AddSystemInfo("Domain", "Anshoo");
            extent.AddSystemInfo("Selenium Version", "2.46");
            extent.AddSystemInfo("Environment", "Prod");
            extent.AddSystemInfo("Host Name", "Test");

            var test = extent.StartTest("Extent", "A very basic step with a few.Logs.").AssignAuthor("Anshoo");
            test.Log(LogStatus.Pass, "Step Info");
            test.Log(LogStatus.Pass, "Step Info");
            test.Log(LogStatus.Pass, "Step Info");
            test.Log(LogStatus.Pass, "Step Info");
            extent.EndTest(test);

            test = extent
                    .StartTest("HTML Tags", "This is a short description")
                    .AssignCategory("Regression", "ExtentAPI", "ExtentAPI");
            test.Log(LogStatus.Info, "You can insert a <a href='http://relevantcodes.com'>link</a> using <p></p> <pre>&lt;a href='http://url'&gt;&lt;/a&gt; tag</pre>");
            test.Log(LogStatus.Info, "This is a <span class='label success'>success label</span> which you can create using: <p></p> <pre>&lt;span class='label success'&gt;description&lt;/span&gt;</pre>");
            test.Log(LogStatus.Info, "This is a <span class='label failure'>fail label</span> which you can create using: <p></p> <pre>&lt;span class='label failure'&gt;description&lt;/span&gt;</pre>");
            test.Log(LogStatus.Info, "This is a <span class='label info'>info label</span> which you can create using: <p></p> <pre>&lt;span class='label info'&gt;description&lt;/span&gt;</pre>");
            test.Log(LogStatus.Info, "This is a <span class='label warn'>warning label</span> which you can create using: <p></p> <pre>&lt;span class='label warn'&gt;description&lt;/span&gt;</pre>");
            extent.EndTest(test);

            test = extent.StartTest("Snapshot test", "This test shows snapshots.").AssignCategory("Snapshots");
            test.Log(LogStatus.Fail, "Snapshot " + test.AddScreenCapture("./1.png"));
            test.Log(LogStatus.Fail, "Snapshot " + test.AddScreenCapture("./2.png"));
            extent.EndTest(test);

            test = extent.StartTest("Test with Nodes", "This example shows a test with 2 child nodes (methods).").AssignAuthor("Anshoo");
            var child1 = extent.StartTest("Child Node 1").AssignCategory("ExtentAPI", "Regression");
            child1.Log(LogStatus.Fail, "Failed Step");
            child1.Log(LogStatus.Fail, "Snapshot " + test.AddScreenCapture("./1.png"));
            var child2 = extent.StartTest("Child Node 2").AssignCategory("ExtentAPI", "Regression");
            child2.Log(LogStatus.Warning, "Warning Step");
            child2.Log(LogStatus.Pass, "Snapshot " + test.AddScreenCapture("./2.png"));
            test.AppendChild(child1);
            test.AppendChild(child2);
            extent.EndTest(test);

            test = extent.StartTest("Test Shows pre block");
            test.AssignCategory("CategoryName");
            test.Log(LogStatus.Skip, "<pre>java.lang.NullPointerException \n" +
                    "at java.lang.String.replace(Unknown Source) \n" +
                    "at com.relevantcodes.extentreports.Logger.Log.Logger.java:63) \n" +
                    "at com.relevantcodes.extentreports.Abstrac.Log.Log(Abstrac.Log.java:64) \n" +
                    "at com.relevantcodes.extentreports.Abstrac.Log.Log(Abstrac.Log.java:73) \n" +
                    "at com.relevantcodes.extentreports.ExtentReports.Log(ExtentReports.java:160) \n" +
                    "at com.mytests.TestOne.testA(TestOne.java:37) \n" +
                    "at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) \n" +
                    "at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) \n" +
                    "at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) \n" +
                    "at java.lang.reflect.Method.invoke(Unknown Source) \n" +
                    "at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84) \n" +
                    "at org.testng.internal.Invoker.invokeMethod(Invoker.java:714) \n" +
                    "at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901) \n" +
                    "at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231) \n" +
                    "at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) \n" +
                    "at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) \n" +
                    "at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) \n" +
                    "at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) \n" +
                    "at java.lang.Thread.run(Unknown Source) \n" +
                "</pre>");
            extent.EndTest(test);

            extent.Flush();
            extent.Close();
        }