简体   繁体   English

单元测试应该在本地计算机上运行吗?

[英]Should Unit Tests Be Run On A Local Machine?

Recently I've been tasked with writing and running unit tests in C# for a desktop application. 最近,我受命用C#为桌面应用程序编写和运行单元测试。 In the past, I've written mainly automated functional/GUI tests. 过去,我主要编写了自动化的功能/ GUI测试。 These get run on dedicated QA machines because these tests can cause crashes, data loss, Blue Screen of Death, etc. Should a similar setup be done for running unit tests? 它们可以在专用的QA机器上运行,因为这些测试可能导致崩溃,数据丢失,蓝屏死机等。是否应该对运行的单元测试进行类似的设置? Are there any risks with running unit tests on my local machine? 在本地计算机上运行单元测试有任何风险吗?

Unit tests should run on your local machine AND on the build server. 单元测试应在本地计算机构建服务器上运行。 They are an invaluable resource as feedback for the developer. 它们是开发人员的宝贵资源。 The DEV should write the unit tests. DEV应该编写单元测试。 Before checking in, he should run the unit tests to make sure he does not break anything. 在签入之前,他应该运行单元测试以确保他没有破坏任何东西。 The build server will then run the unit tests again, in order to make sure nothing it actually broken, and that the integration with other code, if any, succeeded. 然后,构建服务器将再次运行单元测试,以确保它没有实际损坏,并确保与其他代码(如果有)的集成成功。

When the unit tests have run, preferably, the build server should then run integration tests and automated UI tests. 最好运行单元测试后,构建服务器应再运行集成测试和自动UI测试。 When these processes have finished, a build has been produced with no known defects - at least none that is covered by the tests. 这些过程完成后,就生成了没有已知缺陷的构建-至少没有覆盖测试。 In other words a green build means the software integration went well, and the developers can keep checking in - or at some point start doing manual testing before actually releasing a piece of software. 换句话说,绿色的构建意味着软件集成良好,开发人员可以继续检入-或在实际发布软件之前开始进行手动测试。

Software testing nirvana happens when enough tests has been automated, so that the developers and the business can feel safe releasing a product based only on the success of this stream of automated tests. 软件测试必杀技是在足够多的测试自动化后发生的,因此,开发人员和企业仅凭这种自动化测试的成功,就可以放心地发布产品。 In reality, only a few products will be this mature - and some amount of manual testing is required. 实际上,只有少数产品会如此成熟-并需要进行一些手动测试。

Unit tests does not touch external systems or interfaces. 单元测试不涉及外部系统或接口。 Therefore, there are no risks by running them locally. 因此,在本地运行它们没有任何风险。

Unit tests should be so isolated that they can be run on every machine without any further setup. 单元测试应该隔离开来,这样它们可以在每台机器上运行而无需任何进一步的设置。 Unit tests by definition test only functional units on a very granular level without touching external systems (ie database, file system, etc.) 从定义上讲,单元测试仅在不涉及外部系统(即数据库,文件系统等)的情况下,仅对功能单元进行非常细致的测试。

Unit Testing is typically done by the Developers while developing. 单元测试通常由开发人员在开发过程中完成。 So Run it on your Development environment. 因此,请在您的开发环境上运行它。 Probably your Local machine. 可能是您的本地计算机。

well if your local machine is a dev machine I see no risk since the machine is not a production end user machine. 如果您的本地计算机是开发计算机,那么我认为没有风险,因为该计算机不是生产最终用户计算机。 You can also consider TFS Lab management (in case you have Microsoft TFS as ALM / source control system). 您还可以考虑使用TFS Lab管理(如果您将Microsoft TFS作为ALM /源代码控制系统)。 in that case you can create virtual or physical test environment and the application gets deployed and tested in those defined environments. 在这种情况下,您可以创建虚拟或物理测试环境,然后在定义的环境中部署和测试应用程序。

not sure what the names of similar test products are for non TFS scenarios. 不知道非TFS方案中类似测试产品的名称是什么。

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

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