At the top of the module: @safe: later unittest { assertThrown(...) } Ooops. AssertThrown not safe. Changing the top to: version(Unittest) {} else { @safe: } makes it work, but then I'll need to use that idom in all safe modules as assert*Thrown is handly methods.