LyraLearn AI Learning Platform
Exams
← Module 8 Β· Testing .NET Applications
🎧 Listen

Why and What to Test

Automated tests exist to answer one question fast: did this change break something? In a system that decides whether a teaching candidate has met subject matter requirements, "we clicked around and it looked fine" is not an acceptable answer. But testing effort is a budget, and spending it well matters more than spending a lot of it.

The test pyramid, MVC edition

The test pyramid is the classic effort model: many fast unit tests at the base, fewer integration tests in the middle, a thin layer of end-to-end/UI tests on top. Mapped onto a layered MVC app:

The pyramid's point is economics: when a unit test fails you know which rule broke; when a UI test fails you know only that something broke, and you'll spend an hour finding out what.

Business rules first

Your highest-value tests sit where the domain logic lives. "A candidate meets the subject matter requirement when every SMR domain is satisfied by qualifying coursework or a passing exam score" β€” that's a service-layer rule with edge cases (quarter-unit conversion, expired exam scores, partial domain coverage) that will regress during maintenance. Each edge case is one cheap unit test. Aim your effort at code that is (a) decision-heavy and (b) likely to change β€” for this system, the evaluation/matching rules, status transitions, and anything computing units or dates.

What NOT to unit test

Just as important, because bad tests are a maintenance tax forever:

The next lessons build the mechanics: unit tests with mocks, then data access and controllers, then test data and CI.

🧠 Quiz yourself on this lesson →

Ask the AI Tutor

Grounded in the course lessons β€” it cites its sources and says when it doesn't know.