1 module unit_threaded.ut.modules.module_with_attrs; 2 3 import unit_threaded.runner.attrs; 4 import std.exception; 5 6 @HiddenTest("foo") 7 @ShouldFail("bar") 8 @SingleThreaded 9 void testAttrs() { } 10 11 @ShouldFailWith!Exception 12 void testOtherAttrs() {} 13 14 15 @ShouldFail 16 @(1, 2, 3) 17 void testValues(int i) { } 18 19 20 @ShouldFail 21 @("will fail") 22 unittest { 23 assert(0); 24 } 25 26 class TestException : Exception { this(string m) { super(m); } } 27 28 @ShouldFailWith!TestException 29 @("ShouldFailWith that fails due to wrong type") 30 unittest { 31 assert(0); 32 } 33 34 @ShouldFailWith!TestException 35 @("ShouldFailWith that fails due to not failing") 36 unittest { 37 } 38 39 40 @ShouldFailWith!TestException 41 @("ShouldFailWith that passes") 42 unittest { 43 throw new TestException("you won't see this"); 44 } 45 46 47 @Flaky 48 @("flaky that passes eventually") 49 unittest { 50 static int i = 0; 51 if(i++ % 2 == 0) throw new Exception("failed"); 52 } 53 54 @Flaky(1) 55 @("flaky that fails due to not enough retries") 56 unittest { 57 static int i = 0; 58 if(i++ % 2 == 0) throw new Exception("failed"); 59 }