Laporan tingkat hanya melaporkan rangkaian pengujian terakhir yang telah dijalankan.
Saya telah menyiapkan tes Selenium dengan 10 setelan berbeda yang dijalankan secara berurutan. Masalahnya adalah Extent Report hanya mencatat hasil rangkaian terakhir. Saya telah mencoba berbagai cara menerapkan laporan untuk mengumpulkan semua hasil.
Struktur kode: Kelas BaseSetUp - inisialisasi driver (OneTimeSetUp, SetUp, TearDown, OnetimeTearDown)
Panggilan metode umum - mewarisi dari BaseSetUp
PageObject Page - dapatkan semua Objek Halaman
TestSuits - Mewarisi dari metode Umum.
Saya memiliki laporan di kelas BaseSetUp seperti ini:
[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);
}
}
Saya telah melihat beberapa metode di mana laporan sebelumnya ditambahkan ke laporan "baru" yang dibuat, tetapi saya tidak berhasil.
Contoh testcase di salah satu testsuite
[TestCase(TestName = "01_LogIn"), Order(1)]
public void LogIn()
{
LogIn();
string loginAssert = HomePage.expLoginName.Text;
Assert.IsTrue(loginAssert.Contains("Hi, " + username + ""), "Login falied");
}
Ada ide tentang bagaimana saya harus maju?
Laporan jangkauan berjalan V4