Skip to content

Instantly share code, notes, and snippets.

@prashantkumarpathak
Last active September 5, 2021 07:53
Show Gist options
  • Save prashantkumarpathak/f520a6bff72d8110ea328bdc9b4d18d2 to your computer and use it in GitHub Desktop.
Save prashantkumarpathak/f520a6bff72d8110ea328bdc9b4d18d2 to your computer and use it in GitHub Desktop.

Test environment

If we closely look at the design of software under test, there is data flow between various components i.e. output of one component is the input of another. First thought comes to us that within the component there must be a path where logs are getting stored. Before we start the framework, follow one thumb of rule i.e. "Build an easy to maintain and reusable code"

NOTE: Below steps were performed on Mac OS, the programming language used is Python 3 with Robot Framework. Pycharm is used as a development IDE. Robot framework comes with various builtin libraries for API, UI and SSH.

Step#1: Lets create a Python virtual environment for this project. Creating a virtual environment is helpful when shipping this framework to the customer or sharing within the team.

>> python3 -m venv <project folder> # In this case project name is test_automation
>> source test_automation/bin/activate # To activate the virtual env
(test_automation) prashant.pathak Documents %
>> pip install - upgrade pip

Install all your required packages for test automation and freeze it in a requirement.txt within the same virtual env Requirement.txt (used in the python virtual env to install all the dependencies packages in a single run) : Below packages shows the content of the requirement.txt file. When sharing the framework within the team, the team just needs to execute the requirement.txt inside the python virtual env and the test framework is ready to use.

paramiko==2.7.2
pycparser==2.20
PyNaCl==1.4.0
python-dateutil==2.8.1
pytz==2021.1
requests==2.25.1
robotframework==3.2.2
robotframework-archivelibrary==0.4.0
robotframework-csvlib==1.0.2
robotframework-pabot==1.11
robotframework-pythonlibcore==2.2.1
robotframework-requests==0.8.1
robotframework-seleniumlibrary==5.1.1
robotframework-sshlibrary==3.6.0
robotframework-xvfb==1.2.2
robotremoteserver==1.1
scp==0.13.3
selenium==3.141.0
six==1.15.0
urllib3==1.26.3
robotframework-jsonlibrary==0.3.1
robotframework-requestschecker==2.0.0

Step#2: Create a project folder structure. As shown below image

The primary folders that needs to be created for test_automation projects are

Config :

Includes the global variables for all the components. The global variables sample shown below A config file content :

SELENIUM_SPEED = "1s"
SELENIUM_TIMEOUT = "60s"
SELENIUM_IMPLICIT_WAIT = "60s"
BROWSER = "Chrome"
HEADLESS_MODE = "enabled"
DEFAULT_USER = "admin"
SSH_TIMEOUT = "30s"
DEFAULT_TCP_PORT = None
LOCAL_CHORMEDRIVER_PATH = "/usr/local/chromedriver"
### Product Variables Only ###
#Component License Files
LICENSE_FILE = "license.txt"
#All component access details
COMPONENT1_IP = "10.100.1.1"
COMPONENT1_USER = "admin"
COMPONENT1_PASSWORD = "test123"
COMPONENT2_IP = "10.100.1.2"
COMPONENT2_USER = "admin"
COMPONENT2_PASSWORD = "test123"
COMPONENT3_IP = "10.100.1.3"
COMPONENT3_USER = "admin"
COMPONENT3_PASSWORD = "test123"
# API Sessions
COMPONENT1_API_SESSION = "com1"
COMPONENT2_API_SESSION = "com2"
COMPONENT3_API_SESSION = "com3"

Libraries :

This includes all the Python files consisting of functions for a specific task and will be used as keywords in the robot test suites.

Resources :

Includes the common robot keywords for re-usability in all the test suites. This folder can be subdivided based on the type of keywords related to UI, API and SSH.

Tests :

Consists of all the feature wise test suites. For example, testing data flow is considered a common feature for all the components. So, we can add this test under a sub directory called 'common' inside the parent tests folder.

Results :

For storing automation test results.

Step#3: Design the test scenarios to cover the above problem statement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment