Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
IT Security NachrichtenEU-Gesetz zur Cyber-Resilienz ist in Kraft - Netzpalaver(21.09.2026 um 20:29 Uhr)
Malware / Trojaner / VirenMeta Muse AI app flaw lets local malware redirect dictation traffic(21.09.2026 um 21:59 Uhr)
IT Security NachrichteniPhone 18 Pro (Max): Nutzer melden plötzliche Abstürze durch Face ID(21.09.2026 um 21:18 Uhr)
IT Security DownloadsEs wird Zeit, Word zu löschen(21.09.2026 um 21:53 Uhr)
IT NachrichtenAI can't outprompt a shortage of power, water, and land(21.09.2026 um 18:35 Uhr)
IT NachrichtenLondon neocloud Nscale takes its $1B loss to Wall Street(21.09.2026 um 19:15 Uhr)
IT Security NachrichtenEU-Gesetz zur Cyber-Resilienz ist in Kraft - Netzpalaver(21.09.2026 um 20:29 Uhr)
Malware / Trojaner / VirenMeta Muse AI app flaw lets local malware redirect dictation traffic(21.09.2026 um 21:59 Uhr)
IT Security NachrichteniPhone 18 Pro (Max): Nutzer melden plötzliche Abstürze durch Face ID(21.09.2026 um 21:18 Uhr)
IT Security DownloadsEs wird Zeit, Word zu löschen(21.09.2026 um 21:53 Uhr)
IT NachrichtenAI can't outprompt a shortage of power, water, and land(21.09.2026 um 18:35 Uhr)
IT NachrichtenLondon neocloud Nscale takes its $1B loss to Wall Street(21.09.2026 um 19:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Backend Tests

Part of The Coercion Saga — making AI write quality code. The Behavior Gate Quality gates catch syntax. Tests catch behavior. A function that type-checks but returns garbage is worse than one that fails to compile. …

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Part of The Coercion Saga — making AI write quality code.







The Behavior Gate



Quality gates catch syntax. Tests catch behavior. A function that type-checks but returns garbage is worse than one that fails to compile.









The Async Trap



FastAPI is async. Get testing wrong and tests hang or miss real bugs.




# conftest.py
import asyncio
import pytest

@pytest.fixture(scope="session")
def event_loop():
loop = asyncio.new_event_loop()
loop.set_debug(True) # Catches blocking calls
yield loop
loop.close()






set_debug(True) catches time.sleep() instead of asyncio.sleep(), synchronous I/O, libraries that claim async but aren't. One line, whole category of bugs.









Test Client






@pytest.fixture
async def client(session: AsyncSession) -> AsyncGenerator[AsyncClient, None]:
app.dependency_overrides[get_session] = lambda: session
async with AsyncClient(app=app, base_url="http://test") as client:
yield client
app.dependency_overrides.clear()






Endpoint code doesn't know it's being tested. Runs exactly like production.









What to Test



Service layer:




async def test_create_user(session: AsyncSession):
user = await create_user(session, email="[email protected]", password="secret")
assert user.password != "secret" # Should be hashed






Error cases:




async def test_register_duplicate(client: AsyncClient, session: AsyncSession):
await create_user(session, email="[email protected]", password="secret")
await session.commit()

response = await client.post("/auth/register", json={
"email": "[email protected]", "password": "different"
})
assert response.status_code == 409 # Not 500






409 Conflict means you caught it intentionally. 500 means you caught it in a crash.









The Gate






test:backend:
stage: test
image: python:3.12-slim
services:
- postgres:16
variables:
DATABASE_URL: postgresql+asyncpg://postgres:postgres@db:5432/test
before_script:
- pip install uv && cd backend && uv sync --frozen
- uv run alembic upgrade head
script:
- uv run pytest -v --cov=app --cov-report=term-missing --cov-report=html
allow_failure: false






Copy, paste, adapt. It works.









The Point



Tests are the safety net. Refactor with confidence. Ship knowing the code works.



That's the deal.







Next up: [Frontend Tests] -coming soon- — Now prove the UI works too.


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Backend Tests

Thematisch verwandte Begriffe: Backend, Tests · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94494 | jshERP through 3.6 contains a tenant isolation bypass vulnerability that…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick