简体   繁体   English

在CI中运行的监视单元测试

[英]Monitoring unit test that runs in CI

I want to monitor xunit.net tests that are running in CI (if you know similar approaches for nunit it may also helps). 我想监视在CI中运行的xunit.net测试(如果您知道类似的nunit方法也可能会有所帮助)。

Integration tests that were running double in time and I would like to get information like methods call timing and resources usage. 运行时间加倍的集成测试,我想获取诸如方法调用时间和资源使用情况之类的信息。

I started windows performance monitor but it isnt clear to me where the time is being spent inside the test and why it double in execution. 我启动了Windows性能监视器,但是我不清楚测试中的时间花在了哪里,以及为什么它在执行中会加倍。

Any advice? 有什么建议吗? Thanks! 谢谢!

For a high-tech option that might cost you a few dollars, look into a profiling tool. 对于可能要花费几美元的高科技选择,请看一下配置文件工具。 there is a really good one for dotnet called ANTS Performance Profiler that can help you work out where some of your bottlenecks are. 对于dotnet而言,有一个非常好的工具称为ANTS Performance Profiler,它可以帮助您确定某些瓶颈所在。 It will also link to your code to show you exactly where the problems are showing up. 它还将链接到您的代码,以向您确切显示问题出在哪里。

The simplest free (as in only spending your time) approach that I can think of is to introduce a base test class, and use the setup/teardown methods to log timing and other information to either console or file. 我能想到的最简单的免费方法(就是花时间)是引入一个基础测试类,并使用setup / teardown方法将计时和其他信息记录到控制台或文件中。 Alternately you could create a test harness for use within each of your tests, and add the logging there. 或者,您可以创建一个测试工具以在每个测试中使用,并在其中添加日志记录。 A slightly more sophisticated approach would be to use some method of delegation to trigger the Assign/Act/Assert stages of your tests, and apply your logging there. 稍微复杂一点的方法是使用某种委托方法来触发测试的“分配/操作/声明”阶段,并在其中应用日志记录。 Personally, I do all of my C# testing using a product called StoryQ. 就个人而言,我使用名为StoryQ的产品进行所有C#测试。 If I needed something logged, I would introduce a few extension methods to effectively wrapper my logging while still behaving as test steps. 如果我需要记录一些东西,我将介绍一些扩展方法,以有效地包装我的记录,同时仍作为测试步骤。

If it were me though, I'd spend the bucks and choose the profiler. 如果是我,我会花大钱并选择探查器。 It will pay for itself time and again, and really helps you to determine where to invest your time optimizing your code. 它将一次又一次地为自己付出代价,并且确实可以帮助您确定将时间花费在优化代码上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM