vibssingh posted: " HOME In this tutorial, I will explain about Manual Tests in Serenity JUnit5. You can annotate @Test not @Steps as @Manual. In contrast to Junit4 a test method annotated with @Manual will actually be executed. This allows to further specify the e"
In this tutorial, I will explain about Manual Tests in Serenity JUnit5.
You can annotate @Test not @Steps as @Manual.
In contrast to Junit4 a test method annotated with @Manual will actually be executed. This allows to further specify the example using @Step methods and show them the report.
Below is an example where tests are annotated with @Manual with description.
@SerenityTest public class LoginPageDefinitions { @Managed WebDriver driver; @Steps StepLoginPage loginPage; @Steps StepDashboardPage dashPage; @Steps StepForgetPasswordPage forgetpasswordPage; @Test @Title("Login to application should be successful") public void sucessfulLogin() { // Given loginPage.open(); // When loginPage.inputUserName("Admin"); loginPage.inputPassword("admin123"); loginPage.clickLogin(); // Then dashPage.loginVerify(); } @Test @Title("Login to application should be unsuccessful with error message") public void unsucessfulLogin() throws InterruptedException { // Given loginPage.open(); // When loginPage.inputUserName("abc"); loginPage.inputPassword("abc12"); loginPage.clickLogin(); // Then String actualErrorMessage = loginPage.errorMessage(); assertEquals("Invalid credentials", actualErrorMessage); } @Test @Manual void manualDefault() { loginPage.manualStep(); } @Test @Manual(result = TestResult.SUCCESS) void manualSuccess() { loginPage.manualStep(); } @Test @Manual(result = TestResult.COMPROMISED) void manualCompromised() { loginPage.manualStep(); } @Test @Manual(result = TestResult.ERROR) void manualError() { loginPage.manualStep(); } @Test @Manual(result = TestResult.ERROR, reason = "A reason for the error") void manualErrorWithReason() { loginPage.manualStep(); } @Test @Manual(result = TestResult.FAILURE) void manualFailure() { loginPage.manualStep(); } @Test @Manual(result = TestResult.IGNORED) void manualIgnored() { loginPage.manualStep(); } @Test @Manual(result = TestResult.PENDING) void manualPending() { loginPage.manualStep(); } @Test @Manual(result = TestResult.SKIPPED) void manualSkipped() { loginPage.manualStep(); } @Test @Manual(result = TestResult.UNDEFINED) void manualUndefined() { loginPage.manualStep(); } @Test @Manual(result = TestResult.UNSUCCESSFUL) void manualUnsuccessful() { loginPage.manualStep(); } }
StepLoginPage.java
public class StepLoginPage extends PageObject { @Step("Enter Username") public void inputUserName(String userName) { $(By.name("txtUsername")).sendKeys((userName)); } @Step("Enter Password") public void inputPassword(String passWord) { $(By.name("txtPassword")).sendKeys((passWord)); } @Step("Click Submit Button") public void clickLogin() { $(By.name("Submit")).click(); } @Step("Error Message on unsuccessful login") public String errorMessage() { String actualErrorMessage = $(By.id("spanMessage")).getText(); return actualErrorMessage; } @Step("Manual Test Step") public void manualStep() { System.out.println("Verify various status of manual step"); } }
StepDashboardPage.java
public class StepDashboardPage extends PageObject { @Step("Successful login") public void loginVerify() { String dashboardTitle = $(By.id("welcome")).getText(); assertThat(dashboardTitle, containsString("Welcome")); } }
Execute these tests by using the below command in commandline.
mvn clean verify
There are two automated tests and rest all are Manual tests. We have Manual Test marked as Default, SUCCESS, COMPROMISED, ERROR, FAILURE, IGNORED, PENDING, SKIPPED, UNDEFINED and UNSUCCESSFUL.
The execution status looks like as shown below.
The reports are generated under /target/site/serenity. There are 2 types of Reports are generated - index.html and serenity-summary.html. To know how to generate Serenity Reports, please refer tutorials for index.html and serenity-summary.html.
By default, @manual scenarios are marked as pending in the Serenity reports.
All scenarios highlighted by blue color are Pending ones whereas pink color are Broken ones.
Serenity-Summary.html
We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.