-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from osundwajeff/testing
Testing
- Loading branch information
Showing
28 changed files
with
325 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
# Behaviour driven development | ||
|
||
[Behave](https://behave.readthedocs.io/en/latest/) is an agile software development technique. | ||
|
||
Behave installation: | ||
- Created a new conda environment: | ||
```bash | ||
conda create -n testing python | ||
``` | ||
|
||
- Installed `behave` using pip | ||
```bash | ||
pip install behave | ||
``` | ||
|
||
## Gherkin Feature Testing language | ||
|
||
Features are made up of scenarios: | ||
```Gherkin | ||
Feature: feature name | ||
Scenario: some scenario | ||
Given some condition | ||
Then some result is expected. | ||
``` | ||
|
||
## Django test integration | ||
|
||
- There are two projects tha integrate django and behave: | ||
- [django-behave](https://github.com/django-behave/django-behave/blob/master/README.md#how-to-use) | ||
- [behave-django](https://behave-django.readthedocs.io/en/latest/installation.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
# End-to-end testing | ||
|
||
## Introduction | ||
[E2E](https://www.techtarget.com/searchsoftwarequality/definition/End-to-end-testing) | ||
verifies working order of a system from start to end, | ||
taking into account real world scenarios the system can run(simulate user experience) | ||
|
||
Most of the projects of the applications at the company are mainly in Django with a React frontend. | ||
|
||
To accomplish E2E testing, we use [playwright](https://playwright.dev/). | ||
It supports all the major browsers used today. | ||
|
||
## Getting started | ||
|
||
To get started with Playwright, you need to ensure you have playwright installed in your device locally. | ||
There are a variety of playwright packages, but as per our standards, we will use Playwright Node.js package. | ||
|
||
### Installing Node.js | ||
|
||
To set up Node.js in Debian/Ubuntu or Fedora, | ||
the binary distributions for Node.js are available at [Nodesource](https://github.com/nodesource/distributions). | ||
The binary setups are directly installed. | ||
|
||
For NixOS, the configuration can be found at [NixOS packages](https://search.nixos.org/packages). | ||
You can go ahead and search for the Node.js version best suited. | ||
The configuration for that package is then added to `etc/nixos/configuration.nix`. | ||
```nixos | ||
environment.systemPackages = [ | ||
pkgs.nodejs_18 | ||
]; | ||
``` | ||
|
||
For NixOS users, it is an added advantage if `direnv` is installed. | ||
When you navigate into the specific directory e.g., ci-tests, your environment will be set up. | ||
|
||
**NOTE:** For this to work for Nix-OS users, ensure the directory has an `.envrc` and `default.nix` file. | ||
`shell.nix` file also works. | ||
|
||
|
||
### Installing playwright using npm | ||
|
||
At the root of your project directory `Project`, navigate to `playwright`. | ||
|
||
```bash | ||
cd playwright | ||
``` | ||
|
||
In the `playwright` directory, there are two more directories: | ||
|
||
```bash | ||
$ ls | ||
ci-tests staging-tests | ||
``` | ||
|
||
To set up a new playwright project use: | ||
```bash | ||
npm init playwright@latest | ||
``` | ||
|
||
To configure playwright step by step, you will have to: | ||
|
||
- To install all browsers and all its dependencies: | ||
```bash | ||
npx playwright install --with-deps | ||
``` | ||
|
||
- To install one browser and its dependencies | ||
```bash | ||
npx playwright install chromium --with-deps | ||
``` | ||
|
||
### For Continuous Integration(`CI`): | ||
|
||
Playwright does support Continuous Integration. | ||
For more information, visit the [playwright ci docs](https://playwright.dev/docs/ci-intro). | ||
|
||
Navigate to `playwright/ci-tests` directory. | ||
|
||
In the directory ensure the below files are present: | ||
|
||
```bash | ||
$ cd ci-tests | ||
$ ls | ||
package.json playwright.config.ts | ||
``` | ||
|
||
Then you can proceed with setting up playwright: | ||
|
||
- To update npm dependencies | ||
```bash | ||
npm install | ||
``` | ||
|
||
- To install CI dependencies | ||
```bash | ||
npm ci | ||
``` | ||
|
||
- To install playwright package, browsers and linux dependencies | ||
```bash | ||
npx playwright install --with-deps | ||
``` | ||
|
||
- To run tests: | ||
```bash | ||
npx playwright test | ||
``` | ||
By default, this test will run in `headless` mode(No browser will be opened). | ||
|
||
### For staging tests | ||
|
||
In setting up environment for staging tests, it uses the same approach as in setting up for CI. | ||
The only difference is that installing dependencies for CI won't be required. | ||
|
||
**NOTE:** Both `ci-tests` and `staging-tests` directory will have scripts to assist in setting up the environment easily. | ||
The scripts are: | ||
- `create-auth.sh`: Used to create a cookie file with the session state saved. | ||
- `record-test.sh`: Used to record new tests. | ||
- `run-tests.sh`: Used to run tests. | ||
|
||
These scripts check if you have the required environment is set up, if it is not, the script will set up everything. | ||
After setting up the environment, the script will proceed to run the next step. | ||
|
||
- Start off by creating the session state file. | ||
![10](./img/testing-e2e-playwright-10.png) | ||
|
||
1. Shows how to run the script in your terminal | ||
2. The script will prompt you if you want to save the `auth.json` file. | ||
|
||
- Proceed to log in. | ||
![16](./img/testing-e2e-playwright-16.png) | ||
|
||
- The `auth.json` will be created. You can then proceed to record your tests. | ||
![11](./img/testing-e2e-playwright-11.png) | ||
|
||
- To record your tests, proceed to run the next script `record-test.sh`. | ||
The script takes a name argument for the file to be created `./record-test.sh demo`. | ||
![12](./img/testing-e2e-playwright-12.png) | ||
|
||
- The script will open a browser and load the required page. | ||
It will use the session state that was previously created. | ||
![13](./img/testing-e2e-playwright-13.png) | ||
![16](./img/testing-e2e-playwright-17.png) | ||
|
||
- Click on the page elements to record a test. | ||
![18](./img/testing-e2e-playwright-18.gif) | ||
|
||
- To run the tests, use `./run-tests.sh`. | ||
![15](./img/testing-e2e-playwright-15.png) | ||
|
||
- It will open a GUI playwright test runner with all tests. You can then proceed to run the tests. | ||
![14](./img/testing-e2e-playwright-14.png) | ||
|
||
### Alternative: playwright in visual studio code | ||
|
||
Install extension `Playwright extention` | ||
|
||
Click on the vscode's extension icon: | ||
|
||
![Extension](./img/testing-e2e-playwright-1.png) | ||
|
||
Search for `playwright test`, select the below playwright test extension: | ||
|
||
![Playwright extension](./img/testing-e2e-playwright-2.png) | ||
|
||
Install the extension: | ||
|
||
![Playwright extension install](./img/testing-e2e-playwright-3.png) | ||
|
||
On your keyboard, press `ctrl + shift + P`. | ||
Search for `playwright`, select `Install Playwright`. | ||
|
||
![Playwright install](./img/testing-e2e-playwright-4.png) | ||
|
||
It will open up the following menu: | ||
|
||
![set up playwright](./img/testing-e2e-playwright-5.png) | ||
|
||
For option `1`: You can choose to install one or all the browsers. | ||
|
||
For option `2`: | ||
- Use `TypeScript` as a default(current preferred standard). | ||
- You can enable to add `GitHub actions` if the tests are for `CI`. | ||
- Enable to `Install Linux dependencies` if you are on Debian/Ubuntu. | ||
You can check this option if you are installing playwright for the first time. | ||
|
||
Press `Ok` to proceed: | ||
It will install and set up the project. | ||
|
||
![Installation process](./img/testing-e2e-playwright-6.png) | ||
|
||
#### Running playwright tests in vscode | ||
|
||
To run tests in vscode, click on this testing icon. | ||
|
||
![Testing](./img/testing-e2e-playwright-7.png) | ||
|
||
It will scan your `tests` directory for playwright tests. | ||
|
||
![Testing 2](./img/testing-e2e-playwright-8.png) | ||
|
||
To run, click on the triangle icon: | ||
|
||
![Running tests](./img/testing-e2e-playwright-9.png) | ||
|
||
- `1`: Lists down all tests functions. You can test normally and also debug from here. | ||
- `2`: You can run the test functions from here. | ||
- `3`: Shows the test results for each session. | ||
|
||
The tests will run and the results shown. | ||
|
||
For more information, look at the [playwright docs for vscode](https://playwright.dev/docs/getting-started-vscode). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Functional testing | ||
|
||
- Each function is compared to specifications to returnthe required outputs |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Introduction | ||
|
||
Evaluating quality, functioning and performance of software | ||
|
||
Act of examining artifacts and behaviour of software under test by validation and verification. | ||
|
||
It involves: | ||
|
||
- analysing product requirements for completeness and correctness | ||
- reviewing product architecture | ||
- working on improving coding techniques with product developers | ||
- examining program behaviour | ||
|
||
The main goal is normally to detect software failures so that defects may be fixed. | ||
|
||
It may entail: | ||
- examining the code | ||
- examining aspects of the code to ensure it does what it's supposed to do | ||
|
||
Faults and failures in a software my not necessarily mean errors of bugs in the code. It may be a missing feature which is a requirement by the client. | ||
|
||
For further reading: https://www.geeksforgeeks.org/software-testing-basics/ | ||
|
||
## Testing approaches | ||
- There are three testing approaches: | ||
- 1️⃣ Static testing | ||
- 2️⃣ Dynamic testing | ||
- 3️⃣ Passive testing | ||
|
||
### Static testing | ||
|
||
- It is mostly regarded as implicit, involves proofreading, checking syntax and data flows etc. (verification). | ||
|
||
### Dynamic testing | ||
|
||
- It is done when running the program (validation). | ||
- It normally starts when the program is still in development stage to ensure that certain functions work as they are supposed to. | ||
|
||
### Passive testing | ||
- It means verifying the system behaviour without any interaction with the software program. | ||
- In this case no test data is provided but the tester studies logs and traces for specific patterns and specific behaviour. | ||
|
||
Software testing touches on a few concepts: | ||
|
||
- [End-to-end testing](end2endtesting.md) | ||
- [Test driven development](tdd.md) | ||
- [Behaviour driven development](behave.md) | ||
- [Functional testing](functionaltesting.md) | ||
- [Integrated testing](integratedtesting.md) | ||
- [Regression testing](regression.md) | ||
- [System testing](systemtesting.md) | ||
|
||
Frameworks and packages: | ||
|
||
- behave | ||
- playwright | ||
- pytest | ||
- black | ||
- pyperformance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Integration testing | ||
|
||
- Tests how multiple units operate together | ||
- Regarded as similar to vertical E2E testing- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Regression testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# System testing | ||
|
||
It is also referred to as system-level testing/ system integration testing. Some describe it as black-box testing. | ||
|
||
- It evaluates the overall functionality and performance of a complete system. | ||
- It tests if the system meets the specified requirements and if it is ideal to be deployed for end users. | ||
- It is done after integration testing and before acceptance testing. | ||
- For more: https://www.geeksforgeeks.org/system-testing/ | ||
|
||
For tools used in software testing, it is dependent on the software. | ||
- Selenium is a common one, mostly used for python web development projects. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Test driven development |