ralupopa / AltTicTacToe-pytest

Experiment with v2.0.0 AltTester (part of code was generated with Recorder)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setup pytest sample project using virtual env

  1. Install python
  2. Install pip
  3. Create and activate virtual env (using Powershell cmd)
python -m venv venv
.\venv\Scripts\activate
  1. Install pytest using pip (having virtual env activated)
python -m pip install pytest
  1. Install AltTester package using pip
pip install AltTester-Driver

Run tests from cmd

In order for pytest to be able to identify test classes, used prefix test_ for filenames and test functions.

pytest

Use -s in order to see printed output:

pytest -s <specific_file.py>

In order to run tests which use unittest unit testing framework

python -m unittest test_recorder.py

Using allure to generate test reports

Setup

  1. Download the latest allure package zip file from the allure framework GitHub

    1. Unzip the downloaded zip file
    2. Copy the path until bin file (including bin)
    3. Add it to path environment variable
  2. Install allure-pytest adaptor using pip

pip install allure-pytest

Generating reports:

Generate a folder(automatically named allure-report) to save allure reports using the following command:

allure generate
  1. Run the tests using the following command:
pytest --alluredir=allure-report <test_file.py>
  1. View the allure report previously generated
allure serve allure-report

Generate allure-report into one html file

After generating allure-report, when we need to save everything into one html file (to share it); install an external package which builds allure generated folder into one html file:

Requirements: Python 3.6+

pip install allure-combine

allure-combine package implementation and documentation

Then each time after running test, when want to save allure-report in one sharable HTML file:

allure generate -c allure-report -o allure-results-html
allure-combine ./allure-results-html

Pytest useful

Parametrizing test functions using pytest.fixture()

About

Experiment with v2.0.0 AltTester (part of code was generated with Recorder)


Languages

Language:Python 100.0%