/automation-best-practices-java

Automation best practices workshop with Java from Sauce Labs

Primary LanguageJavaMIT LicenseMIT

testing-good

E2E Tests – Examples E2E Tests – Solutions

#testing4good

Testing for Good serves 2 purposes:

  1. To pay it forward to the testing world and help us all upskill 🚀
  2. For us all to help a cause greater than ourselves 🌍
We build pathways for young women of color to embrace the current tech marketplace as builders and creators by introducing them to skills in computer programming and technology.

Radical action is needed if we are to close the opportunity gap for Black women and girls. We lead a global movement to establish equal representation in the tech sector. Black Girls CODE is devoted to showing the world that Black girls can code and do so much more. Together, we are creating stronger economies and more equitable societies—ultimately realizing the true potential of democracy through diversity and inclusion.

While the event is free, Sauce Labs encourages all attendees to donate to Black Girls Code. Sauce Labs Office of Inclusion & Sustainability will match donations up to $2500.

You will learn to:

In this automation best practices workshop you will learn the latest and greatest tools and techniques to drastically improve your testing!

We will focus on a holistic approach of risk mitigation by doing:

  • Functional web testing
    • Create a framework for doing comprehensive web testing
    • Use industry-standard best practices
    • Create functional browser tests using Selenium
  • Many other things in between
    • Accessibility testing
    • Run in massive parallel (100s of tests in < 5 min)
    • Automatically get robust test reports which includes logs + videos

Technologies you will use:

Java

Selenium

Maven

Sauce Labs

GitHub Actions

Table Of Contents

Requirements

This is NOT a beginners course. You will not learn Java testing fundamentals here. However, you will learn a number of amazing skills, techniques, and tools to help you test web applications

  • At least 1 year of Java programming
  • Deep understanding of Selenium WebDriver
  • Deep understanding of OOP
  • Java 8 installed
  • Java IDE installed
  • Git
  • Maven installed
  • Free Sauce account

Your Instructor: Chris Eccleston

Chris Eccleston profile photo

Facts about me:

  • 🏢 Solutions Architect at Sauce Labs
  • 😄 Pronouns: he/him
  • 🏠 Home automation enthusiast
  • 📫 Links:

LinkedIn Twitter Github

Setup

Sign up for account

Sauce Labs

Get your username and api key

Gitpod setup

Open in Gitpod

ℹ️ Gitpod lets you run an entire Dev environment from a browser! You can use this approach if you don't know how to set up a local Java environment.

  1. Once the Gitpod.io URL is loaded, you will need to sign in with the GitHub account you created earlier
  2. Once the development environment is loaded, you should see 'Ready to test!' in the Terminal window in the lower portion of the window, run the following commands in that Terminal to set your SAUCE_USERNAME and SAUCE_ACCESS_KEY:

ℹ️ You can get your Sauce Labs Username and Access Key by going to the Sauce Labs user settings page

eval $(gp env -e SAUCE_USERNAME=<sauce_username>)
eval $(gp env -e SAUCE_ACCESS_KEY=<sauce_access_key>)

Replace <sauce_username> and <sauce_access_key> with your credentials

Once you have run those 2 commands, you can run the following commands to test your environment variables:

echo $SAUCE_USERNAME
echo $SAUCE_ACCESS_KEY

Run sanity tests

mvn test -Dtest=E2ETests -X
Click here to see an example console output.
    Results :

    Tests run: 4, Failures: 0, Errors: 0, Skipped: 3

    [INFO] ------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------
    [INFO] Total time:  12.410 s
    [INFO] Finished at: 2022-07-11T10:06:10-04:00
    [INFO] ------------------------------------------

Local environment setup

Fork then clone the repo

  1. Sign up for a free GitHub account

  2. Fork this repository

    • Make sure you are logged into GitHub
    • Click the Fork in the upper right of the GitHub.
  3. Clone your fork of the repository to your machine. Must have Git installed

git clone URL_OF_YOUR_FORK

Setup environment variables on your system

Mac/Linux
Windows

Navigate to the directory of where you cloned your repo

cd YOUR_FORK_DIR/automation-best-practices/workshop

Run sanity tests

mvn test -Dtest=E2ETests -X
Click here to see an example console output.
  Results :

  Tests run: 4, Failures: 0, Errors: 0, Skipped: 3

  [INFO] ------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------
  [INFO] Total time:  12.410 s
  [INFO] Finished at: 2022-07-11T10:06:10-04:00
  [INFO] ------------------------------------------

✅ 👏 Environment setup is complete if tests passed

Setting data center

By default, the data center selected for our exercises is US_WEST. If you would like to switch to another data center (i.e. EU_CENTRAL), please update the E2ETests with the appropriate data center.

Stay to the end and win a prize!

Stay to the end and 2 lucky people can win a snazzy Backpack!

me

Key

💡 this is a tip

🏋️‍ this is an exercise for you to do

❓ this is a question for us to think and talk about. Try not to scroll beyond this question before we discuss