1 /++
2   A module containing the attributes used to add metadata to your tests
3 
4   Copyright: © 2017 Szabo Bogdan
5   License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file.
6   Authors: Szabo Bogdan
7 +/
8 module trial.attributes;
9 
10 /// This struct is used to mark some test functions
11 struct TestAttribute {
12   ///
13   string file;
14 
15   ///
16   size_t line;
17 }
18 
19 /// This specifies when a setup method must be called
20 struct TestSetupAttribute {
21   /// Run before the suite starts
22   bool beforeAll;
23 
24   /// Run after the suite ends
25   bool afterAll;
26 
27   /// Run before each test
28   bool beforeEach;
29 
30   /// Run after each test
31   bool afterEach;
32 }
33 
34 /// Mark a test
35 TestAttribute Test(string file = __FILE__, size_t line = __LINE__) {
36   return TestAttribute(file, line);
37 }
38 
39 /// Mark a function to be executed before each test
40 TestSetupAttribute BeforeEach() {
41   return TestSetupAttribute(false, false, true, false);
42 }
43 
44 /// Mark a function to be executed after each test
45 TestSetupAttribute AfterEach() {
46   return TestSetupAttribute(false, false, false, true);
47 }
48 
49 /// Mark a function to be executed before the suite starts
50 TestSetupAttribute BeforeAll() {
51   return TestSetupAttribute(true, false, false, false);
52 }
53 
54 /// Mark a function to be executed after the suite ends
55 TestSetupAttribute AfterAll() {
56   return TestSetupAttribute(false, true, false, false);
57 }