Selenide + Rest Assured + Junit5 + Allure for Web, Mobile,and Api Automation
One single framework to automate web, mobile and api.
Preferred Java Version : JDK-11
Libraries Used:
- Selenide for web and mobile automation
- Rest Assured for Api automation
- Junit5 as testing framework
- Allure for reporting
- Owner for properties file management
- Lombok to avoid boilerplates
- PODAM for test data generation
- Java Faker for random data
- AssertJ for fluent assertion of Api
Video tutorials
Sample Web Test
@SmokeTest
class AddEmployeeTest extends WebTestSetup {
private final EmployeeDetails employeeDetails = EmployeeTestData.getRandomEmployeeDetails();
private final LoginDetails loginDetails = LoginTestData.getValidLoginDetails();
@WebTest
void testAddEmployee() {
LoginPage.getInstance()
.loginToApplication(loginDetails)
.navigateToEmployeeInformationPage()
.addNewEmployee(employeeDetails)
.checkWhetherEmployeeCreatedSuccessfully();
}
}
Sample Mobile Test
@RegressionTest
class AddToCartTest extends MobileTestSetup {
@MobileTest
void addAProductToCart() {
ProductDetailsScreen productDetailsScreen = screen(ProductDetailsScreen.class);
productDetailsScreen
.selectProduct()
.checkWhetherAddToCartButtonIsPresent();
}
}
Sample Api Test
@RegressionTest
class CreateUserTest extends ApiTestSetUp {
private final UserDetails userDetails = UserTestData.getUserDetails();
@ApiTest
void createUser() {
Response response = CreateUserApi.createUser(userDetails);
assertThat(response)
.statusCodeIs(201)
.canBeDeserializedTo(CreateUserResponse.class)
.hasKeyWithValue("job", userDetails.getJob())
.andMatchingRule(e-> e.jsonPath().getString("name").equalsIgnoreCase(userDetails.getName()))
.matchesSchemaInFile("create-user-response-schema.json")
.assertAll(); //don't forget to call assertAll
}
}
To run web tests:
mvn clean test -Dgroups=web -Dselenide.browser=chrome
mvn clean test -Dgroups=web -Dselenide.browser=firefox
To run mobile tests:
Local-Android | mvn clean test -Dgroups=mobile -Dselenide.browser=com.tmb.provider.mobile.local.AndroidAppProvider
Local-Ios | mvn clean test -Dgroups=mobile -Dselenide.browser=com.tmb.provider.mobile.local.IosAppProvider
Lambda-Test-Android
- To run your native android app test utilizing a real device on LambdaTest cloud, upload the sample android apk from here using the LambdaTest app upload api. This will give you
app_url
in response which we need to set for lambdaTestAppUrl in config.properties - Add your Lambdatest username and accessKey in config.properties or pass it as system property
- Run below command:
mvn clean test -Dgroups=mobile -Dselenide.browser=com.tmb.provider.mobile.remote.LambdaTestAndroidAppProvider -DlambdaTestAppUrl=lt://APPURL12345
To run api tests:
API - mvn clean test -Dgroups=api
To generate allure report after execution
Install Allure in the machine - brew install allure
Open allure reports - allure serve ./target/allure-results