รวบรวมผลลัพธ์จากชุดการทดสอบทั้งหมดลงในรายงานขอบเขต

รายงานขอบเขตจะรายงานเฉพาะชุดทดสอบล่าสุดที่มีการเรียกใช้เท่านั้น

ฉันได้ตั้งค่าการทดสอบซีลีเนียมโดยใช้ชุดที่แตกต่างกัน 10 ชุดซึ่งดำเนินการตามลำดับ ปัญหาคือว่ารายงานขอบเขตจะบันทึกเฉพาะผลลัพธ์ของชุดสุดท้ายเท่านั้น ฉันได้ลองใช้วิธีต่างๆ ในการนำรายงานไปใช้เพื่อรวบรวมผลลัพธ์ทั้งหมด

โครงสร้างรหัส: BaseSetUp Class - เริ่มต้นไดรเวอร์ (OneTimeSetUp, SetUp, TearDown, OnetimeTearDown)

การเรียกวิธีการทั่วไป - สืบทอดจาก BaseSetUp

PageObject Page - รับวัตถุหน้าทั้งหมด

TestSuits - สืบทอดมาจากวิธีการทั่วไป

ฉันมีรายงานในคลาส BaseSetUp ดังนี้:

[OneTimeSetUp]
    public void Setup()
    {

        try
        {
            extent = new ExtentReports();
            var dir = AppDomain.CurrentDomain.BaseDirectory.Replace("\\bin\\Debug", "");
            var htmlReporter = new ExtentHtmlReporter(dir + "\\Test_Execution_Reports" + "\\Automation_Report" + ".html");
            extent.AddSystemInfo("Environment", "Xylect AT");
            extent.AddSystemInfo("User Name", "Lucas");
            extent = new ExtentReports();
            extent.AttachReporter(htmlReporter);


        }
        catch (Exception e)
        {
            throw (e);
       }}



 [SetUp]
    public void BeforeTest()
    {
        try
        {
            _test = extent.CreateTest(TestContext.CurrentContext.Test.Name);
        }
        catch (Exception e)
        {
            throw (e);
        }
    }


    [TearDown]
    public void AfterTest()
    {
        try
        {
            var status = TestContext.CurrentContext.Result.Outcome.Status;
            var stacktrace = "" + TestContext.CurrentContext.Result.StackTrace + "";
            var errorMessage = TestContext.CurrentContext.Result.Message;
            Status logstatus;
            switch (status)
            {
                case TestStatus.Failed:
                    logstatus = Status.Fail;
                    string screenShotPath = Capture(driver, TestContext.CurrentContext.Test.Name);
                    _test.Log(logstatus, "Test ended with " + logstatus + " – " + errorMessage);
                    _test.Log(logstatus, "Snapshot below: " + _test.AddScreenCaptureFromPath(screenShotPath));

                    break;
                case TestStatus.Skipped:
                    logstatus = Status.Skip;
                    _test.Log(logstatus, "Test ended with " + logstatus);
                    break;
                default:
                    logstatus = Status.Pass;
                    _test.Log(logstatus, "Test ended with " + logstatus);
                    break;
            }


        }
        catch (Exception e)
        {
            throw (e);
        }
    }

   [OneTimeTearDown]
    public void TearDown()
    {

        try
        {

            //zip();
            //Email();
            extent.Flush();
            driver.Close();
            driver.Quit();
        }
        catch (Exception e)
        {

            throw (e);
        }

    }

ฉันเคยเห็นวิธีการสองสามวิธีที่เพิ่มรายงานก่อนหน้าลงในรายงานที่สร้างขึ้น "ใหม่" แต่ฉันไม่สามารถใช้งานได้

ตัวอย่างชุดทดสอบในชุดทดสอบชุดใดชุดหนึ่ง

        [TestCase(TestName = "01_LogIn"), Order(1)]
    public void LogIn()
    {
        LogIn();
        string loginAssert = HomePage.expLoginName.Text;
        Assert.IsTrue(loginAssert.Contains("Hi, " + username + ""), "Login falied");

    }

มีความคิดเห็นใดบ้างว่าฉันควรก้าวไปข้างหน้าอย่างไร?

การรันรายงานขอบเขต V4


person Lucas    schedule 10.09.2019    source แหล่งที่มา
comment
OneTimeSetUp ทำงานทุกครั้งที่ชุดโปรแกรมใหม่เริ่มทำงานหรือไม่ ถ้าอย่างนั้นคุณก็มีปัญหานี้   -  person Sureshmani Kalirajan    schedule 10.09.2019
comment
ใช่. แล้วมันควรจะเป็นอย่างไร?   -  person Lucas    schedule 11.09.2019
comment
ฉันต้องการข้อมูลเพิ่มเติมเกี่ยวกับวิธีการตั้งค่าห้องสวีท? คุณจะกระตุ้นการทดสอบการทำงาน - testng runner หรือวิธีหลักอย่างไร? การสร้างออบเจ็กต์รายงานขอบเขตควรเกิดขึ้นเพียงครั้งเดียวตลอดการดำเนินการของคุณ ดูว่าคุณสามารถสร้างตรรกะเพื่อตั้งค่าเพียงครั้งเดียวและส่งรายงานไปยังห้องสวีทที่เหลือได้หรือไม่   -  person Sureshmani Kalirajan    schedule 11.09.2019


คำตอบ (1)


เพียงคุณไปตามลิงค์นี้ ฉันหวังว่ามันจะช่วยแก้ปัญหาของคุณได้

คุณต้องสร้าง 3 คลาส

BaseFixture.cs
ExtentManager.cs
ExtentTestManager.cs

หลังจากนั้น คุณสามารถเริ่มต้น BaseFixture ได้ในทุกคลาสการทดสอบ

[TestFixture, Parallelizable(ParallelScope.Fixtures)]
    public class MemberLogInOut : BaseFixture

https://github.com/anshooarora/extentreports-csharp/tree/master/ExtentReports/ExtentReports.Tests/Parallel

person murthy    schedule 12.09.2019
comment
ขอบคุณ! ฉันจะลองตั้งค่าตามที่อธิบายไว้ในลิงค์ อย่างไรก็ตาม ฉันได้รับข้อผิดพลาดในคลาส ExtentManager บนเมธอด htlm.Configuration() วิธีการนี้มาจากไหน? - person Lucas; 13.09.2019
comment
สวัสดีลูคัส ขอโทษ ฉันไม่เข้าใจสิ่งที่คุณพูด อย่างไรก็ตาม เป็นไปได้ไหมที่จะแชร์รหัสของคุณที่นี่? ฉันจะพยายาม. คุณใช้ ExtentReports เวอร์ชันใดอยู่ - person murthy; 16.09.2019
comment
ใช้งานได้แล้ว.. ฉันไม่สามารถแชร์รหัสได้จริงๆ ยกเว้นรหัสที่ให้มาจากรายงานขอบเขต เนื่องจากบริษัท ขอบคุณสำหรับความช่วยเหลือ! - person Lucas; 16.09.2019
comment
ดีค่ะ...งานดี. - person murthy; 17.09.2019