Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Red-Green-Refactor in Practice: Fake It, Triangulation, Obvious Implementation and Baby Steps
There are three ways to turn a red test green: obvious implementation when you know the code, fake it when you don't, triangulation when the design is unclear; and every surprising red means a smaller step. Growing CouponValidator live with xUnit v3, we see a banker's rounding surprise, a fake that breaks old tests, verifying a test that was green right away by breaking the code, an Istanbul-time expiry rule with TimeProvider and a small commit on every green, with real output.
What Is TDD? Canon TDD, the Test List and the Real Purpose of Red-Green-Refactor
TDD is not writing lots of unit tests but a discipline of growing behavior in small steps while correcting the design all the time: a test list first, then one test from it, red, green, an optional refactor and an updated list. We look at Kent Beck's Canon TDD, how it differs from Uncle Bob's three laws, and how the list for Bookstore's CouponValidator changes over two loops, with real test output.
Reading Old Integration and E2E Tests: WebApplicationFactory from .NET 6 to 11, Testcontainers 3 to 4, Protractor to Playwright
When reading an old integration test, the first question is which application the factory brings up: a Startup-based factory can compile on .NET 10 and return 404 without ever running Bookstore. With real builds and runs we cover how WebApplicationFactory changed from .NET 6 to 11, .NET 11's ConfigureWebApplicationBuilder hook, the Testcontainers 4 changes, moving off Protractor, and the breaking changes in Playwright 1.58–1.65.
Flaky E2E Tests: Isolation, Parallelism, Retries, Network Mocking and Visual Comparison
A flaky E2E test often points to real nondeterminism in the application: Bookstore's search test was catching a race in which a late HTTP response overwrote the result. With real runs we cover shared data, time zones, page.clock, workers and sharding, the failures retries hide, legitimate uses of page.route, platform differences in toHaveScreenshot and accessibility checks with axe.
End-to-End Testing Bookstore: Bringing Up the API, Angular and the Database Together
Playwright's webServer starts two processes: a .NET host that opens the SQL Server container and runs the API on a real port with WebApplicationFactory.UseKestrel, and ng serve. With real runs we show three surprises in the host, signing in once with a setup project and storageState, preparing test data through the API, combining page objects with fixtures, and UseKestrel ignoring the port with WithWebHostBuilder.
Getting Started with Playwright: Playwright Test or Playwright for .NET, Locators, Auto-Waiting and Trace Viewer
Playwright waits for the element before an action but not for the action's result; leave the result to web-first assertions built with expect(locator). For a .NET + Angular team we compare Playwright Test with Microsoft.Playwright and show with real runs how to write locators from the user's point of view with getByRole and getByLabel, strict mode, codegen, and reading a failed test in the trace viewer.
The Contract Between Angular and the API: OpenAPI Documents, Breaking Change Detection and When to Use Pact
The contract between Angular and the API is carried by an OpenAPI 3.1 document generated at build time and committed; in CI, oasdiff catches breaking changes, while TypeScript types generated from the document and tsc catch breakage in the fields actually used. With real output we explain why the document shows numbers as 'integer or string', the enum, nullable and required pitfalls, how to classify breaking changes and when Pact is needed.
Faking External Dependencies at the Boundary: WireMock.Net, Fake SMTP, FakeTimeProvider and Failure Scenarios
Fake external services at the HTTP and SMTP boundary rather than by mocking your own client: WireMock.Net for the payment and shipping APIs, Mailpit for email, FakeTimeProvider for time. With real runs we show verifying the outgoing request, retry, timeout and circuit breaker really kicking in, POST retries against a slow provider turning into four payments, and a global fake clock freezing Polly.
Real SQL Server with Testcontainers: Container Lifecycle, Migrations and Cleanup Between Tests
Start the SQL Server container once per assembly, open a separate database per test class, build the schema with migrations rather than EnsureCreated, and clean up with Respawn before every test. We measure transaction rollback, a database per test and Respawn on a shared database with the same ten tests, and show that rollback silently does nothing without PreserveExecutionContext and what container reuse really costs.
WebApplicationFactory in Depth: Custom Factory, ConfigureTestServices, Configuration and Test Authentication
Pass test configuration with UseSetting or CreateHost; a value given with ConfigureAppConfiguration never reaches what Program.cs reads before Build. With measurements we show replacing services in a custom factory, telling 401 from 403 with a header-based test authentication handler, redirect and ProblemDetails helpers, the real cost of WithWebHostBuilder, and background services running in tests by accident.
Integration Testing Infrastructure in .NET 10: What Runs Real and What Is Faked?
In this series an integration test runs the API inside the test process with its production pipeline and the database as a real SQL Server container; only external services such as payment, shipping and email are faked at the boundary. We show with real runs how SQLite and InMemory differ in collation, length, precision and transactions, then set up an xUnit v3 + Testcontainers skeleton kept apart from unit tests.
From xUnit v2 to v3 and 4.0: Reading and Migrating Old Test Projects
Migrating an xUnit v2 project to v3 means collapsing the packages into one, making the project an executable and changing a few signatures; the real risk when moving to 4.0 is extensibility code that compiles but behaves differently. A custom ITestCaseOrderer written for 3.x compiled without warnings on 4.0.2 and silently stopped ordering methods. A step-by-step migration with real build errors, dotnet new xunit still producing v2, xunit-console-tool and a checklist.