返回提交历史
Modified
README.md
+115
-4
Modified
XFE各类拓展.NetCore.XUnit.Analyzer/XUnitCodeGenerator.cs
+2
-6
Modified
XFE各类拓展.NetCore.XUnit/XFE各类拓展.NetCore.XUnit.csproj
+2
-2
XFEstudio/XFEExtension.NetCore.XUnit
天假更详细的README描述
580ae00
代码差异
3 个文件
+119
-12
@@ -6,10 +6,9 @@ XUnit测试框架,使得用户不需要编写Main函数,只需要在需要
6
6
7
7
## 示例
8
8
9
#### 快速编写无参测试用例
9
#### 快速编写无参测试用例(CTest和MTest)
10
10
11
11
```csharp
12
using System;
13
12
using XFE各类拓展.NetCore.XUnit;
14
13
15
14
[CTest]
@@ -28,16 +27,15 @@ public class TestClass
28
27
}
29
28
```
30
29
30
31
31
#### 带参数的测试用例
32
32
33
33
```csharp
34
using System;
35
34
using XFE各类拓展.NetCore.XUnit;
36
35
37
36
[CTest]
38
37
public class TestClass
39
38
{
40
[MTest]
41
39
[MTest(1, 2)]
42
40
[MTest(2, 3)]
43
41
[MTest(3, 4)]
@@ -46,4 +44,117 @@ public class TestClass
46
44
Console.WriteLine(a + b);
47
45
}
48
46
}
47
```
48
49
50
#### 使用断言(通过继承类)
51
52
```csharp
53
using XFE各类拓展.NetCore.XUnit;
54
55
[CTest]
56
public class TestClass : XFECode
57
{
58
[MTest(1, 2)]
59
[MTest(2, 3)]
60
public void TestMethod(int a, int b)
61
{
62
Assert(a + b == 3, "不等于3");
63
}
64
}
65
```
66
67
68
#### 使用断言(不继承)
69
70
```csharp
71
using XFE各类拓展.NetCore.XUnit;
72
73
[CTest]
74
public class TestClass
75
{
76
[MTest(1, 2)]
77
[MTest(3, 4)]
78
public void TestMethod(int a, int b)
79
{
80
XFECode.Assert(a + b == 3, "不等于3");
81
}
82
}
83
```
84
85
86
#### 判断返回值是否相等(MRTest)
87
88
```csharp
89
using XFE各类拓展.NetCore.XUnit;
90
91
[CTest]
92
public class TestClass
93
{
94
[MRTest(1, 2, 3)]
95
[MRTest(2, 3, 5)]
96
[MRTest(3, 4, 7)]
97
public int TestMethod(int a, int b)
98
{
99
return a + b;
100
}
101
}
102
```
103
104
105
#### 为测试用例添加描述(CNTest和MNTest)
106
107
```csharp
108
using XFE各类拓展.NetCore.XUnit;
109
110
[CTest("这是一个测试类")]
111
public class TestClass
112
{
113
[MNTest("这是一个测试方法")]
114
public void TestMethod()
115
{
116
Console.WriteLine("Hello World!");
117
}
118
}
119
```
120
121
122
#### 同时添加描述和结果对比(MNRTest)
123
124
```csharp
125
using XFE各类拓展.NetCore.XUnit;
126
127
[CTest("这是一个测试类")]
128
public class TestClass
129
{
130
[MNRTest("这是一个测试方法", 1, 2, 3)]
131
public int TestMethod(int a, int b)
132
{
133
return a + b;
134
}
135
}
136
```
137
138
139
#### 设置测试类的初始化方法(SetUp)
140
141
```csharp
142
using XFE各类拓展.NetCore.XUnit;
143
144
[CTest]
145
public class TestClass
146
{
147
string initWord;
148
[SetUp]
149
public void SetUp()
150
{
151
initWord = "Hello World!";
152
}
153
154
[MTest]
155
public void TestMethod()
156
{
157
Console.WriteLine(initWord);
158
}
159
}
49
160
```
@@ -11,15 +11,11 @@ namespace XFE各类拓展.NetCore.XUnit
11
11
12
12
public void Execute(GeneratorExecutionContext context)
13
13
{
14
string source = $@"
15
namespace XFE各类拓展.NetCore.XUnit
14
string source = $@"namespace XFE各类拓展.NetCore.XUnit
16
15
{{
17
16
public static class XUnitCode
18
17
{{
19
public async static Task Main(string[] args)
20
{{
21
await XFECode.RunTest();
22
}}
18
public async static Task Main(string[] args) => await XFECode.RunTest();
23
19
}}
24
20
}}
25
21
";
@@ -14,7 +14,7 @@
14
14
<PackageReadmeFile>README.md</PackageReadmeFile>
15
15
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.XUnit</RepositoryUrl>
16
16
<PackageTags>Test;XUnit;XFE;Unit</PackageTags>
17
<Version>1.0.3</Version>
17
<Version>1.0.4</Version>
18
18
<PackageLicenseFile>LICENSE</PackageLicenseFile>
19
19
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
20
20
</PropertyGroup>
@@ -37,7 +37,7 @@
37
37
</ItemGroup>
38
38
39
39
<ItemGroup>
40
<PackageReference Include="XFE各类拓展.NetCore" Version="1.5.1" />
40
<PackageReference Include="XFE各类拓展.NetCore" Version="1.5.2" />
41
41
</ItemGroup>
42
42
43
43
</Project>