Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: eSim Automated Tests

on:
push:
pull_request:

jobs:
test:

runs-on: ubuntu-latest

steps:

- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-html pytest-cov
sudo apt update
sudo apt install -y ngspice

- name: Run Integration Tests
run: |
pytest --html=reports/report.html

- name: Upload HTML Report
uses: actions/upload-artifact@v4
with:
name: pytest-report
path: reports/report.html
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ nghdl*
tags
build/
dist/
venv/
__pycache__/
.pytest_cache/
reports/*.html
80 changes: 80 additions & 0 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Automated Integration Testing Framework

This module provides automated integration testing for eSim simulations using pytest and ngspice.

---

## Features

- Automated ngspice simulation execution
- Multi-circuit regression testing
- GitHub Actions CI/CD integration
- HTML test report generation
- Parameterized pytest framework

---

## Folder Structure

```text
integration_tests/
testcases/
utils/
reports/
```

---

## Supported Testcases

- RC Circuit
- RL Circuit
- RLC Circuit

---

## Run Tests

Activate virtual environment:

```bash
source venv/bin/activate
```

Run all tests:

```bash
pytest
```

---

## Generate HTML Report

```bash
pytest --html=reports/report.html
```

---

## CI/CD Pipeline

GitHub Actions automatically runs tests on:
- push
- pull requests

Workflow file:

```text
.github/workflows/tests.yml
```

---

## Technologies Used

- Python
- pytest
- ngspice
- GitHub Actions
- pytest-html
Empty file added integration_tests/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions integration_tests/test_simulations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

from utils.simulator import run_ngspice


circuits = [
"rc.cir",
"rl.cir",
"rlc.cir"
]


@pytest.mark.parametrize("circuit", circuits)
def test_circuit_simulation(circuit):

result = run_ngspice(f"testcases/{circuit}")

assert result.returncode == 0

assert "No. of Data Rows" in result.stdout

assert "Simulation executed from .control section" in result.stdout
Loading