Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Logging & Meta Tests

Logging

Define the operations being done by the application as discrete units of work. Examples: commands, queries, startup, shutdown. Define explicit boundaries between units of work. This makes it easy to log the operations of the application.

  • Log startup scenario together with settings. I.e. read all settings at application startup, and only there.
  • Log commands and queries. For commands, log command type and eventual return value. For queries, log the query type and the query result.
  • Define a logging gateway with convenience methods for logging application events. Define a class that represents an application event and define all known application events in a single, static and application-specific, class. Application events are lower-level than business events. For example: ExecutingCommand, CommandResult, Starting, Started, ShuttingDown, BeginRequest, EndRequest.
  • Application events should have their own event id.
  • Build infrastructure layer that takes care of application events and calls into client code. Client code should only be concerned with business cases. Logging is done in the infrastructure layer.

Meta Tests

Meta tests are in fact a custom type system. These tests, if implemented properly, can extend the C# type system with a type system that is custom to the application. The test runner will then function as a compiler with slightly slower feedback cycle (TeamCity).

Examples: making sure application events have unique event ids, making sure required business events are in place for translation (Marcus&Frank), making sure business models have private, default constructor, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment