Unity Rider IDE NUnit Tests
2020-01-02 本文已影响0人
会打马赛克的小老弟
单元测试(NUnit Tests)
当我们在写一些小代码的时候,需要测试一些性能问题,我们可以借助 IDE 提供的 NUnit Tests
功能来查看代码的性能以及可能出错的问题,而不需要运行整个项目,或者编译整个项目。
在VS 版也提供了这个功能然而在 Rider 这个IDE中,也是借助了一个nunit.framework.dll
这个库两者差不多,不过VS可能需要NGUE这个东西来管理,具体不太清楚VS。
我们接下来看看怎么在 Rider 来测试。
当我们引入DLL后,可写这么一段的代码:

很简单,接下来我们看看控制台。我们打开这两个窗口:

因为笔者是使用Unity的项目,所以在
Configurations
中显示的是Unity配置清单:
我们换一下:

我们也可以发现一个像盾牌的图标亮起:

我们直接点击运行,然后查看
Unit Tests Coverage
窗口,我们就可以看的我们的代码具体的性能了,至于上面的性能怎么解读不在本文范涛内。自此你将会看到这样的界面:
Unit Tests 也是测试通过的:
