### Install Vedro Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md Command to install the Vedro testing framework using pip. Ensure you have Python and pip installed before running this command. ```sh # Make sure you've installed Vedro first $ pip install vedro ``` -------------------------------- ### Install and Automatically Enable Vedro Plugins Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/using-plugins.md Use the `vedro plugin install` command to install multiple Vedro plugins. This command not only installs the specified plugins but also automatically enables them in your `vedro.cfg.py` configuration file, simplifying the setup process while maintaining explicit configuration. ```shell vedro plugin install vedro-gitlab-reporter \ vedro-allure-reporter ``` ```python import vedro_gitlab_reporter import vedro_allure_reporter import vedro class Config(vedro.Config): class Plugins(vedro.Config.Plugins): class GitlabReporter(vedro_gitlab_reporter.GitlabReporter): enabled = True class AllureReporter(vedro_allure_reporter.AllureReporter): enabled = True ``` -------------------------------- ### Install Plugin via Vedro Plugin Manager Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/ai/debug-prompt.md Installs the `vedro-debug-prompt` package using a single command via Vedro's plugin manager for quick setup. ```shell $ vedro plugin install vedro-debug-prompt ``` -------------------------------- ### Install vedro-unittest Plugin Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/unittest-bridge.md Installs the vedro-unittest plugin using a plugin manager for quick setup. This command is executed in the terminal. ```shell $ vedro plugin install vedro-unittest ``` -------------------------------- ### Install vedro-allure-reporter Plugin Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/using-plugins.md Installs the vedro-allure-reporter plugin using pip. This is the first step before configuring the plugin in Vedro. ```shell $ pip install vedro_allure_reporter ``` -------------------------------- ### Install and Enable vedro-httpx Plugin Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/httpx-client.md Installs the vedro-httpx plugin using a plugin manager or pip, and then enables it in the vedro.cfg.py configuration file. ```shell $ vedro plugin install vedro-httpx ``` ```shell $ pip install vedro-httpx ``` ```python # ./vedro.cfg.py import vedro import vedro_httpx class Config(vedro.Config): class Plugins(vedro.Config.Plugins): class VedroHTTPX(vedro_httpx.VedroHTTPX): enabled = True ``` -------------------------------- ### Install Vedro and httpx Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter1-first-steps.md Installs the Vedro testing framework and the httpx library for making HTTP requests, which are essential for interacting with the chat API. ```shell # Install the required packages using pip $ pip install vedro httpx # Install the necessary plugins $ vedro plugin install vedro-d42-validator ``` -------------------------------- ### Vedro Scenario Example Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/flake8-linter.md A Python example demonstrating a Vedro scenario that uses httpx to fetch book details. It includes setup, action, and assertion steps. ```python # ./scenarios/get_book_details.py import vedro import httpx class Scenario(vedro.Scenario): subject = "" def given_book_id(self): self.book_id = 1234 def when_user_retrieves_book(self): self.response = httpx.get(f"/api/books/{self.book_id}") def then_it_should_return_book_details(self): assert self.response.json() == { "id": self.book_id, "title": "The Great Gatsby", "author": "F. Scott Fitzgerald", } ``` -------------------------------- ### Example Vedro Plugin Configuration Source: https://github.com/vedro-universe/vedro-docs/blob/main/blog/2023-05-14-whats-new-vedro-v1.9/index.md This Python snippet illustrates how a Vedro plugin, once installed, is automatically configured and enabled within the 'vedro.cfg.py' file. It shows the class structure required for a plugin to be recognized and activated by Vedro. ```python import vedro import vedro_gitlab_reporter class Config(vedro.Config): class Plugins(vedro.Config.Plugins): class GitlabReporter(vedro_gitlab_reporter.GitlabReporter): enabled = True ``` -------------------------------- ### Install vedro-telemetry Plugin Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/solutions/self-hosted-telemetry.md Installs the vedro-telemetry plugin using the vedro CLI. This command fetches and installs the plugin, making it available for configuration and use in your Vedro test runs. ```bash $ vedro plugin install vedro-telemetry ``` -------------------------------- ### Install vedro-allure-reporter via Plugin Manager Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/allure-reporter.md Quick installation of the Allure Reporter plugin for Vedro using the vedro plugin manager. ```shell $ vedro plugin install vedro-allure-reporter ``` -------------------------------- ### Install Vedro Dependencies Source: https://github.com/vedro-universe/vedro-docs/blob/main/README.md Installs project dependencies using Yarn. This is the initial step before running any development or build commands. ```shell yarn ``` -------------------------------- ### Install Plugin via Pip Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/ai/debug-prompt.md Installs the `vedro-debug-prompt` package using pip, providing an alternative installation method. ```shell $ pip install vedro-debug-prompt ``` -------------------------------- ### Install vedro-allure-reporter via pip Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/allure-reporter.md Manual installation of the Allure Reporter plugin using pip, followed by enabling it in the vedro.cfg.py configuration file. ```shell $ pip install vedro-allure-reporter ``` ```python # ./vedro.cfg.py import vedro import vedro_allure_reporter class Config(vedro.Config): class Plugins(vedro.Config.Plugins): class AllureReporter(vedro_allure_reporter.AllureReporter): enabled = True ``` -------------------------------- ### Install GitLab Reporter (Manual - pip) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/gitlab-reporter.md Installs the vedro-gitlab-reporter package using pip. This is the manual approach for adding the plugin. ```shell $ pip install vedro-gitlab-reporter ``` -------------------------------- ### Install GitLab Reporter (Quick) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/gitlab-reporter.md Installs the vedro-gitlab-reporter plugin using a plugin manager. This is a quick method for adding the plugin to your Vedro project. ```shell $ vedro plugin install vedro-gitlab-reporter ``` -------------------------------- ### List Installed Vedro Plugins (Shell) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/using-plugins.md This command lists all installed plugins for the Vedro testing framework, displaying their name, package, description, version, and enabled status. It helps users manage and track their project's plugins. ```shell $ vedro plugin list ``` -------------------------------- ### Write Vedro Scenarios: Class-Based and Function-Based Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md Demonstrates how to write Vedro tests using both class-based and function-based syntax. Covers the Given-When-Then structure for defining test steps. Requires the 'vedro' library. ```python # scenarios/create_file.py from pathlib import Path as File import vedro class Scenario(vedro.Scenario): subject = 'create file' def given_new_file(self): self.file = File('example.txt') def when_creating_file(self): self.file.touch() def then_file_should_exist(self): assert self.file.exists() ``` ```python # scenarios/create_file.py from pathlib import Path as File from vedro import scenario, given, when, then @scenario() def create_file(): with given('new file'): file = File('example.txt') with when('creating file'): file.touch() with then('file should exist'): assert file.exists() ``` -------------------------------- ### Install coverage.py Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/measuring-coverage.md Install the coverage.py tool, which is essential for tracking executed code during test runs and generating coverage reports. ```sh pip install coverage ``` -------------------------------- ### Run All Vedro Scenarios in a Directory Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md This command executes all test scenarios found within the specified directory. It's the primary way to run your Vedro test suite from the command line, initiating the test discovery and execution process. ```bash $ vedro run scenarios/ ``` -------------------------------- ### Handle Vedro StartupEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The StartupEvent is triggered at the beginning of the test execution. This example shows how to subscribe to this event and access the list of scenarios using a custom plugin. ```python from typing import List from vedro.core import Dispatcher, Plugin, VirtualScenario from vedro.events import StartupEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(StartupEvent, self.on_startup) def on_startup(self, event: StartupEvent) -> None: scenarios: List[VirtualScenario] = event.scenarios print("on_startup", scenarios) ``` -------------------------------- ### Start Telemetry Server Services with Docker Compose Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/solutions/setting-up-self-hosted-telemetry-server.md Starts all services defined in the `docker-compose.yml` file, including the application, database, and Grafana, in detached mode. This command downloads necessary Docker images and launches the containers. ```shell docker-compose up -d ``` -------------------------------- ### Fail Fast On Repeat Example Output Source: https://github.com/vedro-universe/vedro-docs/blob/main/blog/2024-01-13-whats-new-vedro-v1.11/index.md This example demonstrates the output when `--fail-fast-on-repeat` is enabled, showing how the execution is interrupted after a scenario fails on its second attempt. ```shell Scenarios * register ✗ register user via email │ ├─[1/2] ✔ register user via email │ ├─[2/2] ✗ register user via email !!! !!! !!! Interrupted by “RepeaterExecutionInterrupted('Stop repeating scenarios after the first failure')“ !!! !!! !!! # 1 scenario, 0 passed, 1 failed, 0 skipped (0.12s) ``` -------------------------------- ### Install flake8-vedro Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/flake8-linter.md Installs the flake8-vedro package using pip. This command is essential for setting up the linter in your project environment. ```shell $ pip install flake8-vedro ``` -------------------------------- ### Configure vedro-telemetry Plugin Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/solutions/self-hosted-telemetry.md Example Python code demonstrating how to configure the vedro-telemetry plugin in `vedro.cfg.py` by setting various parameters. ```python import vedro import vedro_telemetry class Config(vedro.Config): class Plugins(vedro.Config.Plugins): class VedroTelemetry(vedro_telemetry.VedroTelemetry): api_url = "http://your-telemetry-server.com" project_id = "my-unique-project-id" timeout = 10.0 raise_exception_on_failure = False ``` -------------------------------- ### Start Local Vedro Development Server Source: https://github.com/vedro-universe/vedro-docs/blob/main/README.md Starts a local development server, typically on port 3000. Changes are reflected live without requiring a server restart, facilitating rapid development. ```shell yarn start --port 3000 ``` -------------------------------- ### Install vedro-unittest via pip and Configure Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/unittest-bridge.md Manually installs the vedro-unittest package using pip and then enables the plugin in the Vedro configuration file (vedro.cfg.py). ```shell $ pip install vedro-unittest ``` ```python import vedro vedro.Config.register_plugin(vedro.plugin.unittest.Plugin()) ``` -------------------------------- ### Example Failed Scenario Output Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/ai/debug-prompt.md Demonstrates the output when a Vedro scenario fails, including the AI Debug Prompt file path and a detailed traceback. ```shell Scenarios * ✗ decode base64 encoded string |> AI Debug Prompt: .vedro/tmp/prompt_liywiyo1.md ✔ given_encoded_string ✔ when_user_decodes_string ✗ then_it_should_return_decoded_string ╭───────────────────── Traceback (most recent call last) ─────────────────────╮ │ /scenarios/decode_base64_str.py:20 in then_it_should_return │ │ │ │ 17 self.result = b64decode(self.encoded) │ │ 18 │ │ 19 def then_it_should_return_decoded_string(self): ❱ 20 assert self.result == "banana" │ │ 21 │ ╰──────────────────────────────────────────────────────────────────────────────╯ AssertionError >>> assert actual == expected - 'banana' + b'banana' # --seed 280dc986-e618-4102-aa53-056c2876c00e # 1 scenario, 0 passed, 1 failed, 0 skipped (0.00s) ``` -------------------------------- ### Python Hardcoded Data Example Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter2-data-models.md Illustrates the use of hardcoded string variables for user credentials in a Python script. ```python username = "bob" password = "qweqwe" ``` -------------------------------- ### Flake8 Linter Output Example Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/flake8-linter.md Example output from running the flake8 command, highlighting standard flake8 errors (E302) and custom vedro-specific rules (VDR105). ```shell ./scenarios/get_book_details.py:4:1: E302 expected 2 blank lines, found 1 ./scenarios/get_book_details.py:5:5: VDR105 subject in scenario should not be empty ``` -------------------------------- ### Step Implementation Example (Function-Based) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/best-practices/scenario-based.md Demonstrates implementing test steps using the function-based approach in Vedro. This example shows API interaction and assertion within 'when' and 'then' context managers. ```python with when("user logs in"): response = ChatApi().login(user) with then("it should return success response"): assert response.status_code == 200 ``` -------------------------------- ### Verify Running Docker Services Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/solutions/setting-up-self-hosted-telemetry-server.md Checks the status of all running Docker containers managed by Docker Compose. It helps confirm that the application, database, and Grafana services have started successfully. ```shell docker-compose ps ``` -------------------------------- ### Vedro CLI Filtering Examples Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/basics/selecting-and-ignoring.md Demonstrates how to use Vedro's command-line interface to filter scenarios by path, ignore specific paths, and filter by subject intent. ```cli vedro run --ignore --subject ``` -------------------------------- ### Register Scenario Subject Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter1-first-steps.md Defines the subject of a Vedro scenario, representing the user's intention to achieve a desired outcome. This is the starting point for structuring a test case. ```javascript import { Scenario } from '@vedro/core'; export const registerScenarioSubject = Scenario.subject('Register a new user'); ``` -------------------------------- ### Step Implementation Example (Class-Based) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/best-practices/scenario-based.md Provides an example of implementing specific test steps within a class-based Vedro scenario. It shows how to interact with an API and assert expected outcomes. ```python def when_user_logs_in(self): self.response = ChatApi().login(self.user) def then_it_should_return_success_response(self): assert self.response.status_code == 200 ``` -------------------------------- ### unittest Example: Custom Test Ordering with Fixtures Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/unittest-bridge.md This Python unittest example illustrates how custom test ordering can be achieved using class-level fixtures (`setUpClass`, `tearDownClass`) and sequential test methods. Vedro handles such structures by grouping them into a single scenario for compatibility, rather than enforcing a specific execution order. ```python import unittest class MyTestCase(unittest.TestCase): @classmethod def setUpClass(cls): # Set up shared state ... def test_1(self): # Relies on shared state ... def test_2(self): # Also relies on shared state ... @classmethod def tearDownClass(cls): # Clean up shared state ... ``` -------------------------------- ### Install Flake8-Vedro Linter Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/features/anti-flaky/index.md Installs the Flake8-Vedro plugin, which adds specific linting rules for Vedro test scenarios to the Flake8 linter. ```shell $ pip install flake8-vedro ``` -------------------------------- ### Use Vedro Context in Class-Based Scenario (Python) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md Demonstrates how to use the `existing_file` context within a class-based Vedro scenario. The context is called in a `given` step to set up the file prerequisite before performing actions and assertions. ```python import vedro from contexts.existing_file import existing_file class Scenario(vedro.Scenario): subject = 'write data to existing file' def given_existing_file(self): self.file = existing_file() def when_writing_data(self): self.file.write_text('banana') def then_file_should_contain_written_data(self): assert self.file.read_text() == 'banana' ``` -------------------------------- ### Run scenarios with tags and selective discoverer Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/exp/selective-discoverer.md Combines the selective discoverer with other scenario filtering mechanisms, such as tags. This example runs scenarios from a specific directory that are tagged with 'API'. ```shell $ vedro run --exp-selective-discoverer scenarios/auth/ --tags API ``` -------------------------------- ### Example Output of Vedro Repeater Plugin Source: https://github.com/vedro-universe/vedro-docs/blob/main/blog/2022-09-04-whats-new-vedro-v1.7/index.md Illustrates the console output when the Vedro Repeater plugin runs tests multiple times. Each test scenario is shown with its repetition count (e.g., [1/2], [2/2]), followed by a summary indicating the total repetitions and seed used. ```shell Scenarios *   ✔ create user  │ ├─[1/2] ✔ create user (0.20s)  │ ├─[2/2] ✔ create user (0.20s)  ✔ delete user  │ ├─[1/2] ✔ delete user (0.10s)  │ ├─[2/2] ✔ delete user (0.10s)  # --seed 1658e13e-2b3f-4f69-9132-cf8051ed018f # repeated x2 # 2 scenarios, 2 passed, 0 failed, 0 skipped (0.40s)  ``` -------------------------------- ### Define Vedro Context for Existing File in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md Defines a reusable Vedro context that creates a specified file if it doesn't exist. This context returns a `pathlib.Path` object for the file, simplifying file operations within tests. ```python import vedro from pathlib import Path as File @vedro.context def existing_file(filename: str = 'example.txt') -> File: file = File(filename) file.touch() return file ``` -------------------------------- ### Project Structure Example Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/best-practices/scenario-based.md Illustrates a typical directory structure for organizing scenarios within a Vedro project. This structure promotes modularity and scalability by grouping related test files. ```text * chat_api/ └── scenarios/ ├── auth/ │ ├── register_new_user.py │ ├── login_as_registered_user.py │ └── try_to_login_as_nonexisting_user.py ├── send_message/ │ ├── send_message.py │ └── try_to_send_message_as_unauthorized_user.py └── get_messages/ ├── get_messages.py └── try_to_get_messages_as_unauthorized_user.py ``` -------------------------------- ### Run Vedro Tests with Coverage Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/measuring-coverage.md Execute Vedro tests while enabling coverage tracking. This command starts the coverage measurement and runs all scenarios in the specified directory. ```sh coverage run -m vedro run scenarios/ ``` -------------------------------- ### Define Basic Vedro Plugin Structure (Python) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md Demonstrates the fundamental structure of a Vedro plugin, inheriting from `Plugin` and implementing the `subscribe` method. This is the starting point for creating custom extensions. ```python # ./custom_plugin.py from vedro.core import Dispatcher, Plugin, PluginConfig class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: pass class Custom(PluginConfig): plugin = CustomPlugin ``` -------------------------------- ### Use Vedro Context in Function-Based Scenario (Python) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md Illustrates the integration of the `existing_file` context into a function-based Vedro scenario. The context is invoked within a `given` block to prepare the test environment, followed by `when` and `then` steps for execution and verification. ```python from vedro import scenario, given, when, then from contexts.existing_file import existing_file @scenario() def write_data_to_existing_file(): with given('existing file'): file = existing_file() with when('writing data'): file.write_text('banana') with then('file should contain written data'): assert file.read_text() == 'banana' ``` -------------------------------- ### Python Test Failure Example Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter2-data-models.md Demonstrates a typical test failure scenario in Python when a user registration process is attempted with already existing data, resulting in a 400 Bad Request status code. ```terminal $ vedro run Scenarios * ✗ register new user ✔ given_new_user ✔ when_guest_registers ✗ then_it_should_return_success_response ╭─────────────────────────── Traceback (most recent call last) ─────────────────────────╮ │ ./scenarios/first_scenario.py:17 in then_it_should_return_success_response │ │ │ │ 14 │ │ self.response = httpx.post(f"{API_URL}/auth/register", json=self.user) │ │ 15 │ │ │ │ 16 │ │ def then_it_should_return_success_response(self): ❱ 17 │ │ assert self.response.status_code == 200 │ │ 18 │ │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ AssertionError: assert 400 == 200 + where 400 = .status_code # 1 scenario, 0 passed, 1 failed, 0 skipped (0.28s) ``` -------------------------------- ### Example Output of Rich Reporter with Skipped Tests Source: https://github.com/vedro-universe/vedro-docs/blob/main/blog/2022-09-04-whats-new-vedro-v1.7/index.md Provides a sample console output from the Vedro Rich Reporter, demonstrating how skipped tests are now displayed by default. The report clearly distinguishes passed, failed, and skipped scenarios, along with execution times and a summary. ```shell Scenarios *   ✔ create user (0.20s)  ✔ delete user (0.10s)  ○ update user (0.00s)  # --seed 3de2f365-bd1b-4eb0-8bc8-9f5432cabad5 # 3 scenarios, 2 passed, 0 failed, 1 skipped (0.30s)  ``` -------------------------------- ### Running Vedro Parameterized Scenarios Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/features/parameterized-scenarios.md Example command to execute parameterized scenarios using the Vedro test runner from the terminal. The output shows how scenarios with interpolated subjects are reported. ```shell vedro run ``` -------------------------------- ### Vedro CLI Plugin Management Commands Source: https://github.com/vedro-universe/vedro-docs/blob/main/blog/2023-05-14-whats-new-vedro-v1.9/index.md These commands provide functionalities for managing plugins within the Vedro testing framework, including installation, enabling, and discovering popular plugins. ```APIDOC vedro plugin install - Description: Installs a specified Vedro plugin and automatically enables it in the 'vedro.cfg.py' configuration file. - Parameters: - plugin_name (string): The name of the plugin package to install (e.g., 'vedro-gitlab-reporter'). - Effect: Adds the plugin to the project's dependencies and updates 'vedro.cfg.py' to enable it. vedro plugin top - Description: Displays a list of the most popular Vedro plugins, including their descriptions, PyPI URLs, and popularity metrics. - Parameters: None. - Output: A formatted table showing plugin details. ``` -------------------------------- ### Apply Allure labels to tests Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/allure-reporter.md Example of applying standard Allure labels (Epic, Feature, Story) and custom labels to Vedro scenarios using the allure_labels decorator. ```python import vedro from vedro_allure_reporter import allure_labels, Story, Epic, Feature @allure_labels( Epic("User Profile Management"), Feature("Updating Profile Details"), Story("Profile Picture Update") ) class Scenario(vedro.Scenario): subject = "update profile picture" ... @allure_labels(AllureLabel("smoke", "true")) class Scenario(vedro.Scenario): subject = "update profile picture" ... ``` -------------------------------- ### HTTP Client Integration with Vedro Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/best-practices/scenario-based.md Shows how to integrate an HTTP client, like vedro-httpx, into Vedro tests. This example defines a ChatApi class that inherits from SyncHTTPInterface for making requests. ```python from vedro_httpx import Response, SyncHTTPInterface class ChatApi(SyncHTTPInterface): def login(self, username: str, password: str) -> Response: return self._request("POST", "/auth/login", json={ "username": username, "password": password }) ``` -------------------------------- ### Run Scenarios Filtered by Allure Labels Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/allure-reporter.md This command-line usage demonstrates how to execute specific Vedro scenarios based on their assigned Allure labels. The `--allure-labels` argument accepts key-value pairs to filter scenarios, allowing for targeted test runs, for example, by 'epic' or 'feature'. ```shell $ vedro run --allure-labels epic="User Profile Management" feature="Updating Profile Details" ``` -------------------------------- ### Handle Vedro StepRunEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The StepRunEvent is fired when a step starts running. This example demonstrates how to subscribe to this event and access the StepResult object. ```python from vedro.core import Dispatcher, Plugin, StepResult from vedro.events import StepRunEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(StepRunEvent, self.on_step_run) def on_step_run(self, event: StepRunEvent) -> None: step_result: StepResult = event.step_result print("on_step_run", step_result) ``` -------------------------------- ### Handle Vedro ScenarioRunEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The ScenarioRunEvent is triggered when a scenario starts running. This example shows how to subscribe to this event and access the ScenarioResult object. ```python from vedro.core import Dispatcher, Plugin, ScenarioResult from vedro.events import ScenarioRunEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(ScenarioRunEvent, self.on_scenario_run) def on_scenario_run(self, event: ScenarioRunEvent) -> None: scenario_result: ScenarioResult = event.scenario_result print("on_scenario_run", scenario_result) ``` -------------------------------- ### Run Scenarios in Random Order (Vedro CLI) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/features/scenario-ordering.md Executes Vedro scenarios in a random order to uncover test dependencies. This command requires no specific dependencies beyond the Vedro CLI installation. ```shell $ vedro run --order-random ``` -------------------------------- ### Clone Vedro Telemetry API Repository Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/solutions/setting-up-self-hosted-telemetry-server.md Clones the `vedro-telemetry-api` repository from GitHub to your local machine. This is the first step to obtaining the necessary files for setting up the server. ```shell git clone https://github.com/vedro-universe/vedro-telemetry-api.git ``` -------------------------------- ### Vedro Scenario-Based Tests in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/best-practices/scenario-based.md Demonstrates Vedro's scenario structure using both class-based and function-based approaches. Each snippet illustrates the Given steps for setup, the When step for the primary action, and the Then steps for asserting outcomes, following the AAA pattern. ```Python import vedro from contexts import opened_url_shortener class Scenario(vedro.Scenario): subject = "shorten url" def given_opened_shortener(self): self.page = opened_url_shortener() def given_entered_url(self): self.page.fill_url("https://vedro.io/docs/quick-start") def when_user_shortens_url(self): self.page.click_shorten_button() def then_it_should_shorten_url(self): shortened_url = self.page.get_shortened_url() assert shortened_url ``` ```Python from vedro import scenario, given, when, then from contexts import opened_url_shortener @scenario() def shorten_url(): with given("opened shortener"): page = opened_url_shortener() with given("entered url"): page.fill_url("https://vedro.io/docs/quick-start") with when("user shortens url"): page.click_shorten_button() with then("it should shorten url"): shortened_url = page.get_shortened_url() assert shortened_url ``` -------------------------------- ### Test File Renaming with Multiple Effects (Python Class-based) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md Demonstrates a Vedro scenario using a class-based approach to test a single file renaming action. It verifies multiple outcomes: the new file name, its existence, and the non-existence of the original file. This showcases testing multiple effects stemming from one primary action. ```python import vedro from contexts.existing_file import existing_file class Scenario(vedro.Scenario): subject = 'rename existing file' def given_existing_file(self): self.original_file = existing_file('file.txt') def when_renaming_file(self): self.renamed_file = self.original_file.rename('new_file.txt') def then_renamed_file_should_have_correct_name(self): assert self.renamed_file.name == 'new_file.txt' def then_renamed_file_should_exist(self): assert self.renamed_file.exists() def then_original_file_should_no_longer_exist(self): assert not self.original_file.exists() ``` -------------------------------- ### Register New User Scenario Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter3-contexts.md A basic Vedro scenario demonstrating the process of registering a new user. This snippet sets up the initial state for user creation. ```javascript import TemplateScenario from './TemplateScenario'; import { registerScenarioFinal } from './snippets'; ``` -------------------------------- ### Validate Response Against Schema Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter2-data-models.md Demonstrates validating a response body against a defined data model (NewUserSchema). Includes examples of a correct response and responses with incorrect username or missing password fields, showing expected validation errors. ```python response_body = { "username": "bob", "password": "qweqwe" } assert response_body == NewUserSchema # No Errors ``` ```python response_body = { "username": "x", "password": "qweqwe" } assert response_body == NewUserSchema # d42.ValidationException: # - Value at _['username'] must have at least 3 elements, but it has 1 element ``` ```python response_body = { "username": "alice", "pass": "qweqwe" } assert response_body == NewUserSchema # d42.ValidationException: # - Key _['password'] does not exist ``` -------------------------------- ### Test File Renaming with Multiple Effects (Python Function-based) Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/quick-start.md Illustrates a Vedro scenario using a function-based approach to test a single file renaming action. It verifies multiple outcomes: the new file name, its existence, and the non-existence of the original file. This highlights testing multiple effects stemming from one primary action. ```python from vedro import scenario, given, when, then from contexts.existing_file import existing_file @scenario() def rename_existing_file(): with given('existing file'): original_file = existing_file('file.txt') with when('renaming file'): renamed_file = original_file.rename('new_file.txt') with then('renamed file should have correct name'): assert renamed_file.name == 'new_file.txt' with then('renamed file should exist'): assert renamed_file.exists() with then('original file should no longer exist'): assert not original_file.exists() ``` -------------------------------- ### Navigate to Telemetry API Directory Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/solutions/setting-up-self-hosted-telemetry-server.md Changes the current directory to the cloned `vedro-telemetry-api` repository. This ensures subsequent commands are executed in the correct context. ```shell cd vedro-telemetry-api ``` -------------------------------- ### Install vedro-git-changed Plugin Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/features/anti-flaky/index.md Installs the vedro-git-changed plugin, which enables running only the tests that have changed relative to a specified git branch. ```shell $ vedro plugin install vedro-git-changed ``` -------------------------------- ### Chat Platform API Endpoints Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter1-first-steps.md Overview of key API endpoints for the chat platform, including authentication, sending messages, and retrieving messages. These endpoints are used to interact with the chat service. ```APIDOC POST /auth/register - Register a new user with a username and password. POST /auth/login - Authenticate an existing user. POST /chats//messages - Send a message to a chat with the specified chat_id. A new chat will be created if it doesn't already exist. GET /chats//messages - Retrieve messages for a chat with the specified chat_id. ``` -------------------------------- ### Configure Allure Reporter Plugin in vedro.cfg.py Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/using-plugins.md Shows how to explicitly enable and configure the vedro-allure-reporter plugin within the `vedro.cfg.py` file. ```python import vedro_allure_reporter import vedro class Config(vedro.Config): class Plugins(vedro.Config.Plugins): class AllureReporter(vedro_allure_reporter.AllureReporter): enabled = True ``` -------------------------------- ### Run Vedro Tests Verbose Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter1-first-steps.md Executes all test scenarios located in the `scenarios/` directory using the Vedro test runner. The `-v` flag increases the verbosity of the test output, providing more detailed information about the test run, which is particularly useful for identifying and troubleshooting issues when a scenario fails. ```shell $ vedro run -v ``` -------------------------------- ### Register Scenario When Step Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter1-first-steps.md Defines the 'when' step in a Vedro scenario, representing the primary action or interaction with the system under test, such as making an API call. ```javascript import { Scenario } from '@vedro/core'; export const registerScenarioWhen = Scenario.when('User registers with valid credentials', async () => { // Perform the primary action, e.g., call the API }); ``` -------------------------------- ### Handle Vedro StepFailedEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The StepFailedEvent is fired when a step fails. This example demonstrates how to subscribe to this event and access the StepResult object. ```python from vedro.core import Dispatcher, Plugin, StepResult from vedro.events import StepFailedEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(StepFailedEvent, self.on_step_failed) def on_step_failed(self, event: StepFailedEvent) -> None: step_result: StepResult = event.step_result print("on_step_failed", step_result) ``` -------------------------------- ### Handle Vedro StepPassedEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The StepPassedEvent is triggered when a step passes. This example shows how to subscribe to this event and access the StepResult object. ```python from vedro.core import Dispatcher, Plugin, StepResult from vedro.events import StepPassedEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(StepPassedEvent, self.on_step_passed) def on_step_passed(self, event: StepPassedEvent) -> None: step_result: StepResult = event.step_result print("on_step_passed", step_result) ``` -------------------------------- ### Register Scenario Given Step Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter1-first-steps.md Defines the 'given' step in a Vedro scenario, which handles the arrangement of initial conditions and preparation of necessary data before the primary action. ```javascript import { Scenario } from '@vedro/core'; export const registerScenarioGiven = Scenario.given('User is on the registration page', async () => { // Setup initial conditions or data here }); ``` -------------------------------- ### Handle Vedro ScenarioFailedEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The ScenarioFailedEvent is triggered when a scenario fails. This example shows how to subscribe to this event and access the ScenarioResult object. ```python from vedro.core import Dispatcher, Plugin, ScenarioResult from vedro.events import ScenarioFailedEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(ScenarioFailedEvent, self.on_scenario_failed) def on_scenario_failed(self, event: ScenarioFailedEvent) -> None: scenario_result: ScenarioResult = event.scenario_result print("on_scenario_failed", scenario_result) ``` -------------------------------- ### Handle Vedro ScenarioPassedEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The ScenarioPassedEvent is fired when a scenario passes. This example demonstrates how to subscribe to this event and access the ScenarioResult object. ```python from vedro.core import Dispatcher, Plugin, ScenarioResult from vedro.events import ScenarioPassedEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(ScenarioPassedEvent, self.on_scenario_passed) def on_scenario_passed(self, event: ScenarioPassedEvent) -> None: scenario_result: ScenarioResult = event.scenario_result print("on_scenario_passed", scenario_result) ``` -------------------------------- ### Handle Vedro ScenarioSkippedEvent in Python Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/writing-plugins.md The ScenarioSkippedEvent is fired when a scenario is skipped. This example demonstrates how to subscribe to this event and access the ScenarioResult object. ```python from vedro.core import Dispatcher, Plugin, ScenarioResult from vedro.events import ScenarioSkippedEvent class CustomPlugin(Plugin): def subscribe(self, dispatcher: Dispatcher) -> None: dispatcher.listen(ScenarioSkippedEvent, self.on_scenario_skipped) def on_scenario_skipped(self, event: ScenarioSkippedEvent) -> None: scenario_result: ScenarioResult = event.scenario_result print("on_scenario_skipped", scenario_result) ``` -------------------------------- ### Python Data Generation with d42 Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter2-data-models.md Shows how to generate random data conforming to the NewUserSchema using the d42 library's fake function. ```python from d42 import fake fake(NewUserSchema) # {'username': 'mwpd', 'password': 'EMiqcS2L9 x6UgxUuirjT9'} fake(NewUserSchema) # {'username': 'kqnhsrqito', 'password': 'XXlYxBaiXAvzj5Yp9pdR'} fake(NewUserSchema) # {'username': 'tzybe', 'password': 'Hr67Wxm6WLLLkhHFJm3SjA'} ``` -------------------------------- ### AllureReporter Plugin Parameters Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/using-plugins.md Defines the configurable parameters for the AllureReporter plugin, including report directory and attachment options. ```python class AllureReporter(PluginConfig): plugin = AllureReporterPlugin # Set directory for Allure reports report_dir: Path = Path("./allure_reports") # Attach tags to Allure report attach_tags: bool = True # Attach artifacts to Allure report attach_artifacts: bool = True ``` -------------------------------- ### Configure Vedro RichReporter to Show Steps Source: https://github.com/vedro-universe/vedro-docs/blob/main/blog/2023-05-14-whats-new-vedro-v1.9/index.md This configuration snippet demonstrates how to enable the 'show_steps' parameter for the 'RichReporter' in Vedro. When set to 'True', it ensures that individual test steps are displayed in the report, even for successful scenarios, providing more detailed execution insights. ```python class RichReporter(vedro.plugins.director.rich.RichReporter): show_steps = True ``` -------------------------------- ### Run single scenario file with selective discoverer Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/exp/selective-discoverer.md Activates the experimental selective discoverer and specifies a single Python file to run scenarios from. This bypasses standard Python import mechanisms for faster startup. ```shell $ vedro run --exp-selective-discoverer scenarios/login_via_email.py ``` -------------------------------- ### Login Scenario Without Context Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter3-contexts.md Illustrates a user login scenario that fails because the necessary prerequisite (user registration) is not met. This highlights the need for context management. ```javascript import TemplateScenario from '@site/src/components/TemplateScenario'; import { loginScenarioWithoutContext } from './snippets'; ``` -------------------------------- ### Running Vedro with Default Reporters Source: https://github.com/vedro-universe/vedro-docs/blob/main/blog/2025-06-155-whats-new-vedro-v1.14/index.md Illustrates the command to run Vedro tests after configuring default reporters in `vedro.cfg.py`. When default reporters are set, running `vedro run` will automatically use them without needing explicit command-line flags. ```shell $ vedro run ``` -------------------------------- ### Display Top Vedro Plugins Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/using-plugins.md The `vedro plugin top` command allows users to discover popular plugins within the Vedro community. It outputs a list of the most widely-used plugins, including their descriptions and popularity metrics, helping users stay updated and find beneficial tools for their projects. ```shell vedro plugin top ``` -------------------------------- ### Custom Runner Options Example Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/integrations/pycharm-plugin.md Demonstrates how to add custom arguments to the Vedro runner configuration within PyCharm to modify test execution behavior, such as enabling detailed timing or step output. ```shell --show-timings --show-steps ``` -------------------------------- ### API: Temporary File and Directory Creation Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/guides/temporary-files.md Provides functions for creating temporary files and directories within the configured temporary root directory. `create_tmp_file` creates a file with optional prefix and suffix, while `create_tmp_dir` creates a directory with similar options. Both return `Path` objects. ```APIDOC create_tmp_file(*, suffix: Optional[str] = None, prefix: Optional[str] = None) -> Path Creates a temporary file in the configured temporary root directory. - `suffix`: Optional suffix for the filename (e.g., ".txt") - `prefix`: Optional prefix for the filename (e.g., "log_") - **Returns**: A [`Path`](https://docs.python.org/3/library/pathlib.html#basic-use) object representing the created file. Internally, `create_tmp_file` uses Python's [`tempfile.NamedTemporaryFile`](https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile) with `delete=False`. create_tmp_dir(*, suffix: Optional[str] = None, prefix: Optional[str] = None) -> Path Creates a temporary directory in the configured temporary root directory. - `suffix`: Optional suffix for the directory name - `prefix`: Optional prefix for the directory name - **Returns**: A [`Path`](https://docs.python.org/3/library/pathlib.html#basic-use) object representing the created directory. Internally, `create_tmp_dir` uses Python's [`tempfile.mkdtemp`](https://docs.python.org/3/library/tempfile.html#tempfile.mkdtemp). ``` -------------------------------- ### GitHub Actions Configuration for Changed Tests Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/features/anti-flaky/index.md An example GitHub Actions workflow that triggers on pushes to branches (excluding main) and runs changed tests against the main branch using Vedro. ```yaml # .github/workflows/run_changed_tests.yml on: push: branches-ignore: - 'main' paths: - 'scenarios/**' jobs: run_changed_tests: runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' - name: Install Dependencies run: pip install -r requirements.txt - name: Run Changed Tests run: vedro run --changed-against-branch=main -N 10 --order-random ``` -------------------------------- ### Login Scenario With Context Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/tutorial/api/chapter3-contexts.md Demonstrates a successful user login scenario by utilizing the `registered_user` context. This ensures the user exists before the login attempt, leading to a passing test. ```javascript import TemplateScenario from '@site/src/components/TemplateScenario'; import { loginScenarioWithContext } from './snippets'; ``` -------------------------------- ### GitLab CI Configuration for Changed Tests Source: https://github.com/vedro-universe/vedro-docs/blob/main/docs/features/anti-flaky/index.md An example GitLab CI configuration that uses the vedro-git-changed plugin to run tests modified against the main branch, along with random ordering and multiple runs. ```yaml # .gitlab-ci.yml run_changed_tests: stage: test image: python:3.11 before_script: - pip install -r requirements.txt script: - vedro run --changed-against-branch=main -N 10 --order-random only: refs: - branches changes: - scenarios/**/* ```