Marks a test method.
xUnit.net does not require an attribute for a test class; it looks for all test methods in all public (exported) classes in the assembly.
Assert.Throws
Record.Exception
xUnit.net has done away with the ExpectedException attribute in favor of Assert.Throws.
We believe that use of [SetUp]is generally bad. However, you can implement a parameterless constructor as a direct replacement.
We believe that use of[TearDown] is generally bad. However, you can implementIDisposable.Dispose as a direct replacement.
To get per-fixture setup, implement IUseFixture<T> on your test class.
To get per-fixture teardown, implement IUseFixture<T> on your test class.
Set the Skip parameter on the[Fact] attribute to temporarily skip a test.
Set the Timeout parameter on the [Fact] attribute to cause a test to fail if it takes too long to run. Note that the timeout value for xUnit.net is in milliseconds.
[Category]
Set arbitrary metadata on a test
Theory (data-driven test).
MSTest and xUnit.net support generic versions of this method
NotSame
Same
Contains
(on CollectionAssert)
n/a
DoesNotContain
Ensures that the code does not throw any exceptions
xUnit.net alternative:
Assert.True(false, "message")
Assert.True(x > y)
GreaterOrEqual
Ensures that a value is in a given inclusive range (note: NUnit and MSTest have limited support for InRange on their AreEqual methods)
IsAssignableFrom
Empty
False
IsType
Assert.True(double.IsNaN(x))
Assert.False(obj is Type);
NotEmpty
IsNotType
NotNull
Null
True
Assert.True(x < y)
LessOrEqual
NotInRange
Ensures that a value is not in a given inclusive range
Ensures that the code throws an exact exception
参考资料