The aim of this framework is to use Spring Boot to create a test automation framework for your functional tests with Selenium Java and Cucumber with TestNG.
- Spring Boot is a popular application development framework in the Java community. Spring Boot simplifies the developer life by handling most of the routine activities.
- Dependency Injection : Easy to create specific objects in our Page Objects, test classes automatically. Spring will just give it to you!!
- WebDriver Manager : Manage web driver life cycle automatically using Spring Boot.
- Page Objects : Create reusable page components and get them injected into Step def and Test
- Parallel test execution : Create multiple threads, manage web drivers and run tests in parallel etc with clear thread specific scope.
- Executing tests in multiple environments (DEV / QA / STG / PRD): To manage environment specific properties like URLs, user credentials etc via property files.
- Cucumber feature files : Driving tests by writing Cucumber feature files.
- Local vs Remote Grid : Execute your tests in local & in remote selenium grid by simply switching Spring profiles easily.
- One of the main advantages of using Springboot in automation framework is writing less code — a lot of configuration management, object management is done is Spring via simple annotations
mvn clean install -DskipTests -DskipCucumber
mvn clean test
mvn clean test -Dcucumber.filter.tags="@Framework"
-> run with default profilemvn clean test -P [remote-sit, remote-uat, uat, sit, local]
-> run with different profiles (default: localmvn clean test -Dparallelcount=10 -Dbrowser=chrome
-> run with 10 threads and on default chromemvn clean test -Dparallelcount=10 -Dcucumber.filter.tags="@Framework"
-> run with 10 threads and on default chromemvn clean test -P uat -Dparallelcount=10 -Dcucumber.filter.tags="@Framework"
-> run with 10 threads in UAT env and on default chromeTestRunner.java
is meant to be run from CLI withmvn clean test
- this will detect the
@serial
and run accordingly
- this will detect the
-
TestRunnerLocal.java
is meant to be run from UI- whereby, it disregards the rule of parallelism. All tests will be run in serial regardless of
@serial
or not - mainly for debugging purpose
- by default, it'll pick up the maven profile that has default true activation (eq.
qa
orlocal
)
- whereby, it disregards the rule of parallelism. All tests will be run in serial regardless of
-
Please take note below points before execution:
- Please select proper maven profile from Maven toolbar
- Once selected, click on Reload All Maven Projects to ensure selected profile is loaded before execution
- Every switching of profile, above 2 steps are required to avoid non-deterministic profile being loaded
- If profile not loaded properly, wrong URL might be hit (eq. we wanted to test
UAT
but hittingSIT
environment)
- If profile not loaded properly, wrong URL might be hit (eq. we wanted to test
- Optinally, set the runner environment variable to
spring.profiles.active=<profile_name>
- SpringBoot - Entire framework is built on top of it
- Cucumber - BDD style feature files
- Selenium Java
- TestNG - Execution
- Poiji - Excel Reader
- Ashot - Screenshot Lib
- Hamcrest Assertion
- Cucumber-Reporting
- Cluecumber-reporting
- Log4j2 - logging
- Excel to POJO Mapper
- Build in environment switcher for UAT/SIT/Remote-UAT/Remote-SIT/Local
- Built-in custom tag to control browser, parallelism, api/ui test
- terminateOnExit configuration to prevent browser from terminating
- Code separation between framework and test
@nobrowser
scenario that doesn't require browser (eq. API-only)@serial
scenario that require to be run in serial (default: parallel)@chrome
force the scenario to only run in Chrome and implicitly@serial
@firefox
force the scenario to only run in firefox and implicitly@serial
- maven profile will set the
spring.prof
property - application.properties will reference it and set active profile
[email protected]@
- all property in this file will be served as default value
- if other profile
qa
orremote
does specify, it'll use it instead (overwrite the app.prop file)
- Steps for excel-POJO generator
- create the model class
Person implements ScenarioModel
which using lombok@Data
- this model must at least has
String Scenario
attribute
- this model must at least has
- create the bean in
GeneralConfig
that returnList<Person>
- this is where the reading from Excel happens
- To use it in test, first
@Autowired List<Person> personList;
(this to get List of objects from step 2) - get
@Autowired GeneralUtils utils;
object- use the object to retrieve 1 Person object based on
scenario
name - eq.
Person person = utils.getData(personList, strScenario, Person.class;
- use the object to retrieve 1 Person object based on
- create the model class
- handling of multiple excel sheets to be combined in single POJO
- handling of different browsers needs
- pre-baked REST-API
- TestNG and Cucumber and API side-by-side
- Add ExtentTest Report
-
Email:
[email protected]
-
LinkedIn:
https://www.linkedin.com/in/sakthivel-iyappan/