build framework from scratch code example

Example 1: build framework from scratch

Firstly I would Set up Environment: Install JDK, MAVEN, INTELLIJ IDE
Than I would  Create Maven project
- ArtifactID - name of your project
- GroupID - identifies your project uniquely across all projects
After that I would Add Dependencies from Maven Repository like
- Selenium Java
- Cucumber
- JRE System library 1.8 in <properties>
- TestNG
- WebDriverManager_BoniGarcia
- Cucumber Java
- Cucumber TestNG
- Apache POI.XML
- APACHE POI
- JDBC
- Restassured
- Gson
After Adding all dependencies I would Create framework Structure (packages)
- Pages where I keep webelements and methods
- POJO / Beans
i. Custom classes
- My Runner class has 
i. Cukesrunner - generates codes and stores html report to target
ii. Smoke
iii. Regression
- StepDefinitions has Actual codes and hook class
- Tests is Data driven tests
- JDBC
- API
- I would create Utilities and under utilities I would create
1) ConfigurationReader
2) Driver class (Singleton)
3) browserUtils
4) DBUtils
5) ApiUtils
-I would create Configuration.properties
- Also Testng_runner.xml
-.I would also Create feature folder with feature file in resources
-. After I finish writing your scenario,
run MY cukesRunner with dryRun=true, this will give
you implementation code that you will store in
StepDefinition class

I run my code using runner class - run codes and generate
cucumber report and html reports
8. Send framework to GitHub or SVN
Firstly I would Create new repo
Than Copy git url and go to eclipse
After that I would Configure git repo and add the url
After Right clicking project, click team, click commit and
I’ll be in git staging
 NOW MY CODE IS IN GITHUB
9. Next is JENKINS INTEGRATION
 Jenkins is
1) Open source automation server
2) Helps to automate the non-human part of
the software development process
3) Allows continuous integration
5) Port is 8081 localhost in my company
---To run your project in Jenkins
1) I Login to Jenkins account
2) Create project - freestyle
3) Install plugins -cucumber report and git
4) Under source code management choose
git and past git url
5) Build trigger - choose to build periodically
6) Invoke top-level maven
1. Maven version; MAVEN_HOME
2. Goals; clean verify -
Drunner=smoke_runner.xml
7) Under post-build actions
1. Choose cucumber reports
2. Choose editable email notify
8) Editable email notification
1. Attach build log; choose build log
2. Click advanced settings
9) Failure-Any
1. Click advanced
2. Recipient list - email address who will
receive the report. Add comma if multiple
3. Click add trigger - like failure always
4. Attach build log; select attach build log
5. Save
10) Final Step
1. Click build now and test will run and
gives your cucumber report

Example 2: create framework from scratch

1. Set up Environment: 
Install JDK, MAVEN, INTELLIJ IDE
2. Create Maven project
● ArtifactID - name of your project
● GroupID - identifies your project uniquely across
all projects
3. Add Dependencies from Maven Repository
● Selenium Java
● Cucumber Sandwich
● JRE System library 1.8 in <properties>
● TestNG
● WebDriverManager_BoniGarcia● Cucumber Java
● Cucumber TestNG
● Apache POI.XML
● APACHE POI
● JDBC
● Restassured
● Gson
● Log4j
4. Create framework Structure (packages)
● Pages
i. Webelements and methods
● POJO / Beans
i. Custom classes
● Runner
i. Cuckesrunner - generates codes and stores
html report to target
ii. Smoke
iii. Regression
● StepDefinitions
i. Actual codes and hook class
● Tests
i. Data driven tests
● JDBC
● API
● Utilities1) ConfigurationReader
2) Driver class (Singleton)
3) browserUtils
4) DBUtils
5) ApiUtils
● Configuration.properties
● Testng_runner.xml
1. One of the runner class Call the packages
with com.app.utilities
5. Create feature folder with feature file
(.feature) in resources
● File executable specification written in a gherkin
language
6. After you finish writing your scenario,
run your cukesRunner with dryRun=true, this will give
you implementation code that you will store in
StepDefinition class
7. How to run your code?
● Use runner class - run codes and generate
cucumber report and html reports
8. Send framework to GitHub or SVN
● Create new repo
● Copy git url and go to eclipse
● Configure git repo and add the url
● Right click project, click team, click commit and
you’ll be in git staging● NOW YOUR CODE IS IN GITHUB
9. Next is JENKINS INTEGRATION
● Jenkins
1) Open source automation server
2) Helps to automate the non-human part of
the software development process
3) Allows continuous integration
4) Development practice that requires dev to
integrate code into a shared repo at reg intervals
5) Port is 8081 localhost