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
参考资料
出处:https://www.cnblogs.com/gaochundong/p/mstest_nunit_xunit_comparisons.html
您的资助是我最大的动力!金额随意,欢迎来赏! 付款后有任何问题请给我留言。
如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的【推荐】按钮。 如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的【关注我】。(●'◡'●)
因为,我的写作热情也离不开您的肯定与支持,感谢您的阅读,我是【Jack_孟】!
本文来自博客园,作者:jack_Meng,转载请注明原文链接:https://www.cnblogs.com/mq0036/p/15400859.html
【免责声明】本文来自源于网络,如涉及版权或侵权问题,请及时联系我们,我们将第一时间删除或更改!
posted on 2021-10-13 10:06 jack_Meng 阅读(156) 评论(0) 编辑 收藏 举报