Skip to content

Breeding-Insight/taf

Repository files navigation

TEST AUTOMATION FRAMEWORK

Breeding Insight UI Test Automation Framework

Features

  • Create tests using Gherkin syntax
  • Execute tests on Chrome and Firefox
  • Execute multiple tests at the same time
  • CI/CD integration ready

Components

Requirements

To run tests locally, you need to install the following: NodeJS Java JRE or JDK Version Control Client Visual Studio Code

Visual Studio Code Plugin Configuration
Cucumber (Gherkin) Full Support Edit settings.json file and include the following:
"cucumberautocomplete.steps":["src/step_definitions/*.js"],
"cucumberautocomplete.strictGherkinCompletion": true,
Cuke Step Definition Generator none
Gherkin Table Formatter none

Quick Start

  1. Clone the repository. (https://github.com/Breeding-Insight/taf.git)
  2. Install dependencies required to run the tests:
npm install
  1. Run tests
npm run test:chrome

Running Tests Locally

Files to change:

  • nightwatch.conf.js (change launch_url under default to your local url)
  • workspace.code-workspace (change server to local:)

Scripts to run tests are in package.json. One can add additional scripts locally to run a subset of scenarios with a particular tag, ie running all scenarios tagged as @SmokeTests:

"test:chromeSmokeTests": "mkdirp report && cucumber-js --require cucumber.conf.js --tags @SmokeTests --require src/step_definitions src/features --format @cucumber/pretty-formatter --format json:report/cucumber_report.json --world-parameters \"{\\\"browser\\\":\\\"chrome\\\"}\"; npm run report"

and then run it in terminal as

npm run test:chromeSmokeTests

Cucumber report by default will be saved to a folder and be overwritten with subsequent runs.

NOTE: If you are not using docker you may need to modify nightwatch.conf.js to change the "launch_url" in the test_settings/docker, to your local host and port. Example:

docker: {
  launch_url: "http://biproxy",
},

TO

docker: {
  launch_url: "http://localhost:8080",
},

Database Assumptions

The implemented scenarios assume the following data is set up on BI:

Users

Name Email System Role
Christian christian@mailinator.com System Administrator
Cucumber Breeder cucumberbreeder@mailinator.com
Cucumber Member cucumbermember@mailinator.com
TrailMix Breeder trailmix@mailinator.com

Programs

Name Species Users (role)
Snacks Grape Cucumber Breeder (Program Administrator)
Cucumber Member (Read Only)
Christian (Program Administrator)
Trail Mix Grape Cucumber Breeder (Read Only)
TrailMix Breeder (Program Administrator)
Christian (Program Administrator)

Automated Database Setup

There is a script setup_local_db.sh that will setup your bidb and brapi-server databases assuming bi-docker-stack and taf repos are at the same level in the filesystem and default docker services/ports are used.

Gherkin Conventions

Setting Values

  • Entering a string in a text field use "sets"
    When user sets "abcdef@test.com" in email field

Interacting with controls

  • Interacting with controls, use "selects"
    When user selects "United States" in Country dropdown
    When user selects "Apple, Banana, Pear" in combo box
    When user selects "Yes" in 'Are you hungry' radio button box
    When user selects "Here" link
    When user selects "Cancel" button

Validating controls

  • Visibility of a control, use "see" and "not see"
    Then user can see "Snacks" button
    Then user can not see "Cancel" link

Running Tests With Selenium Docker and BI-Docker-Stack

TAF can launch browser on a Selenium docker container and run tests on bi-docker-stack.

Prerequisite:

  • Docker Desktop

Clone the following repositories:

Configuration:

  • Set API_BASE_URL environmental variable to http://biproxy

  • Set WEB_BASE_URL environmental variable to http://biproxy

  • Set JWT_DOMAIN environmental variable to biproxy

  • Set REGISTERED_DOMAIN environmental variable to biproxy

  • Update the host's host file Windows : C:\Windows\System32\drivers\etc\host Unix: /etc/hosts Add the following line "127.0.0.1 biproxy"

  • Set the browser to "docker.chrome". In package.json, set browser to "docker.chrome". e.g. "--world-parameters "{\"browser\":\"docker.chrome\"}""

Starting the containers

  • For running specific branch code, make sure code is checked out in bi-docker-stack sub repo and go to the bi-docker-stack folder and execute
docker-compose -f docker-compose.yml -f docker-compose-dev.yml up -d
  • For running latest development branch, go to the bi-docker-stack folder and execute
docker-compose -f docker-compose.yml -f docker-compose-qa.yml up -d
  • Go to TAF folder and execute
docker-compose up -d

Releases

No releases published

Packages

No packages published