XUnit测试框架,使得用户不需要编写Main函数,只需要在需要测试的类或者方法上面加上相对于的特性即可。
[CTest]
//[CTest]
//可添加多个测试用例
public class TestClass
{
[MTest]
//[MTest]
//[MTest]
//可添加多个测试用例
public void TestMethod()
{
Console.WriteLine("Hello World!");
}
}
[CTest]
public class TestClass
{
[MTest(1, 2)]
[MTest(2, 3)]
[MTest(3, 4)]
public void TestMethod(int a, int b)
{
Console.WriteLine(a + b);
}
}
[CTest]
public class TestClass : XFECode
{
[MTest(1, 2)]
[MTest(2, 3)]
public void TestMethod(int a, int b)
{
Assert(a + b == 3, "不等于3");
}
}
[CTest]
public class TestClass
{
[MTest(1, 2)]
[MTest(2, 3)]
public void TestMethod(int a, int b)
{
XFECode.Assert(a + b == 3, "不等于3");
}
}
[CTest]
public class TestClass
{
[MRTest(1, 2, 3)]
[MRTest(2, 3, 5)]
[MRTest(3, 4, 7)]
public int TestMethod(int a, int b)
{
return a + b;
}
}
[CTest("这是一个测试类")]
public class TestClass
{
[MNTest("这是一个测试方法")]
public void TestMethod()
{
Console.WriteLine("Hello World!");
}
}
[CTest("这是一个测试类")]
public class TestClass
{
[MNRTest("这是一个测试方法", 1, 2, 3)]
public int TestMethod(int a, int b)
{
return a + b;
}
}
[CTest]
public class TestClass
{
string initWord;
[SetUp]
public void SetUp()
{
initWord = "Hello World!";
}
[MTest]
public void TestMethod()
{
Console.WriteLine(initWord);
}
}
public class TestClass
{
[SMTest]
public static void TestMethod()
{
Console.WriteLine("Hello World!");
}
}