使用功能C#执行所有单元测试
是否可以在控制台应用程序中执行所有C#单元测试(Xunit
)?因此,最终用户可以在运行程序时看到结果? 假设我们有简单的切换案例
菜单,例如:
- 做某事,
- 做一些不同的
- 运行单元测试。
因此,当来自用户键盘的输入等于3个项目的所有单元测试时,执行了结果?
感谢您的帮助
Is there a way to execute all of the C# unit tests (xUnit
) within the console application? So that the end user can see the results while running the program?
Let's say that we have simple switch case
menu like:
- Do something,
- Do something different
- Run unit tests.
So that when the input from user's keyboard equals 3 all of the unit tests from the project are executed and the result is printed?
Thanks in an advance for the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的测试活在一个名为
mytest.csproj
的C#项目中,您将通过dotnet test myTest.csproj
。如果您想在自己的应用程序中执行此操作,则可以使用
process.start
这样的:这将开始测试运行。
如果您也想获得测试输出,则可以按照以下答案: htttps://stackoverflow.com/a/a/4291965/ 4919526
Assuming that your tests live in a C# project called
MyTest.csproj
, you'd start them from the CLI viadotnet test MyTest.csproj
.If you want to do this from within your own application, you could use
Process.Start
like this:That will start the test run.
If you want to get the test output as well, you could follow this great answer: https://stackoverflow.com/a/4291965/4919526