Skip to content

Commit

Permalink
Edited Project Specific Testing page based on latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yemaneberhan-Lemma authored and hussainweb committed Dec 21, 2024
1 parent b188069 commit 2e01729
Showing 1 changed file with 84 additions and 2 deletions.
86 changes: 84 additions & 2 deletions docs/func_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,92 @@ This project aims to facilitate automated functional and visual regression check

* `npm run vr-dev` (*To run visual tests on dev env*)

For more details about custom scripts, please refer to the package.json file.
For more details about custom scripts, please refer to the `package.json` file.

4. **Test Scripts and Tagging**

We maintain a comprehensive set of test scripts to validate functionality, security, and performance across the application. These scripts are modular, reusable, and categorized to cover different testing scenarios effectively.

To further enhance the flexibility and organization of these scripts, we use **CypressGrep**, a powerful library for tagging and filtering tests. Tagging allows developers to focus on specific subsets of tests, enabling efficient execution tailored to the current requirements.

**Tagging Test Scripts**

Test scripts are categorized using tags such as `critical-path`, `security`, and `expensive`, which provide the following benefits:

* **Selective Execution**: Run only the tests relevant to a feature or scenario.
* **Efficient Debugging**: Exclude resource-intensive tests (`expensive`) during development.
* **Targeted Coverage**: Combine or exclude tags for precise control over the test suite.

Tags are integrated seamlessly with CypressGrep, ensuring smooth execution both locally and in CI environments.

**Tag Names**

While custom tags can be defined to suit project needs, the following are commonly used tags:

* **critical-path**: For tests that verify core functionalities essential for system stability.

* **security**: For tests that validate security mechanisms (e.g., input sanitization, access control).

* **expensive**: For resource-intensive tests that require selective execution.

* **regression**: For tests ensuring that existing features remain functional after changes.

* **performance**: For tests measuring system performance under various conditions.

**Adding Tags to Test Scripts**

To add tags to your test scripts, use the `tags` property in the test definition:

```javascript
describe('Test Script Title', { tags: ['tag-name 1', 'tag-name 2'] }, () => {
// test script code goes here
});
```

**Running Tagged Tests**

Tagged tests can be filtered and executed using the following commands:

* Run tests tagged as `critical-path`:

```bash
npx cypress run --env grepTags=critical-path
```

* Combine multiple tags:

```bash
npx cypress run --env grepTags="critical-path,security"
```

* Exclude specific tags:

```bash
npx cypress run --env grepTags="-expensive"
```

**Integration in CI/CD**

In our CI pipeline, tagged tests are executed using specific workflows. For instance:

* **Excluding expensive tests**:

```yaml
- name: Cypress Test (excluding expensive tests)
run: ddev cypress-run --env grepTags=-expensive
```
* **Running expensive tests (scheduled)**:
```yaml
- name: Run Expensive Tests
run: ddev cypress-run --env grepTags=expensive
```
We can have a separate workflow file for expensive or scheduled test script runs.
## Reporting
TBD
We ensure transparency and actionable insights from test executions using automated reporting tools integrated with our CI pipeline. These reports provide a summary of tests executed, including totals for passed, failed, and skipped tests, along with a breakdown by tags (e.g., critical-path, security). For failed tests, detailed failure logs, including error messages, stack traces, screenshots, and videos, are generated to aid in debugging and resolution.
Feel free to customize the script to suit your specific requirements :)

0 comments on commit 2e01729

Please sign in to comment.