Updated testing methodology to not create test scripts and just test in main code.
This commit is contained in:
@@ -30,7 +30,7 @@ See [preferences/communication.md](preferences/communication.md) for full detail
|
|||||||
|
|
||||||
## Always Do
|
## Always Do
|
||||||
|
|
||||||
- **Tests first:** Always provide a way to immediately test/run the code you write
|
- **No test files:** Don't create test files; I'll run the code directly to verify it works
|
||||||
- **No credentials in code:** Secrets go in `.env` files; always provide a `.env.example`
|
- **No credentials in code:** Secrets go in `.env` files; always provide a `.env.example`
|
||||||
- **Consistent style:** Follow the conventions for the language in use — see preferences files
|
- **Consistent style:** Follow the conventions for the language in use — see preferences files
|
||||||
- **Ask before big changes:** Clarify scope before rewriting or restructuring
|
- **Ask before big changes:** Clarify scope before rewriting or restructuring
|
||||||
|
|||||||
@@ -101,18 +101,8 @@ Import-Module "$script:AppRoot\Modules\ProjectName.psm1" -Force
|
|||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
- Use **Pester** for unit testing
|
- Do **not** create test files — I'll run the code directly to verify it works
|
||||||
- Always provide a Pester test file alongside new functions
|
- If asked to write tests, use **Pester** with `Invoke-Pester -Path .\Tests\ -Output Detailed`
|
||||||
- At minimum, test: happy path, expected failure cases, and edge cases
|
|
||||||
- Run tests with: `Invoke-Pester -Path .\Tests\ -Output Detailed`
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
# Tests/Get-UserConfig.Tests.ps1
|
|
||||||
Describe "Get-UserConfig" {
|
|
||||||
It "Returns default config when file does not exist" { ... }
|
|
||||||
It "Loads config from valid .psd1 file" { ... }
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Comments
|
## Comments
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ ProjectName/
|
|||||||
├── README.md
|
├── README.md
|
||||||
├── Modules/
|
├── Modules/
|
||||||
│ └── ProjectName.psm1 # Shared functions, config loading, helpers
|
│ └── ProjectName.psm1 # Shared functions, config loading, helpers
|
||||||
├── Tests/
|
|
||||||
│ └── *.Tests.ps1 # Pester test files
|
|
||||||
└── Release-Notes/
|
└── Release-Notes/
|
||||||
├── v1.0.md
|
├── v1.0.md
|
||||||
└── v1.1.md
|
└── v1.1.md
|
||||||
@@ -53,15 +51,12 @@ project-name/
|
|||||||
├── routers/
|
├── routers/
|
||||||
│ ├── auth.py
|
│ ├── auth.py
|
||||||
│ └── [resource].py
|
│ └── [resource].py
|
||||||
├── utils/
|
└── utils/
|
||||||
└── tests/
|
|
||||||
└── test_[resource].py
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Rules:**
|
**Rules:**
|
||||||
- `.env` is never committed — `.env.example` always is
|
- `.env` is never committed — `.env.example` always is
|
||||||
- Each resource (users, items, etc.) gets its own model, schema, and router file
|
- Each resource (users, items, etc.) gets its own model, schema, and router file
|
||||||
- Tests live inside `backend/app/tests/`
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -137,10 +137,8 @@ services:
|
|||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
- Use **pytest** with **pytest-asyncio** for async tests
|
- Do **not** create test files — I'll run the code directly to verify it works
|
||||||
- Always provide a test for each router endpoint at minimum (happy path + 1 failure case)
|
- If asked to write tests, use **pytest** with **pytest-asyncio**; use a separate test DB, never the real one
|
||||||
- Use a separate test database — never run tests against the real DB
|
|
||||||
- Run with: `pytest -v`
|
|
||||||
|
|
||||||
## Comments
|
## Comments
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user