Run specific suits xUnit

时间:2019-05-31 11:48:00

标签: c# .net-core xunit xunit.net rider

Due to lack of documentation for xUnit I came here.
I'm trying to find a way of separating my tests into suits. So far I have some tests that interact with database, I'd like to test them separately from my unit tests. Moreover, I'd like to mark the whole classes, I am not mixing unit and integration tests in one class.
The best would be to run specific tests suits for the whole solution, but per project would also be nice.
Is it possible in xUnit? How could I do it?

I use dotnet core 2.2, Rider and xUnit 2.4.0

1 个答案:

答案 0 :(得分:0)

对于有同样问题的任何人,我都会发布从Fabio文档中获取的答案,该文档发送了指向评论的链接。
就我而言,我将分别添加名称为UnitTests的文件夹和名称空间,这些文件夹和名称空间将仅包含我的单元测试。然后,我将使用--filter选项仅运行包含完全限定名称的UnitTests部分的测试。
来自文档:
dotnet test --filter XUnit-运行其FullyQualifiedName包含XUnit的测试。在vstest 15.1+中可用。