UnitTest 项目的代码与源代码同步吗?
我有一个名为 - UnitTestProject 的 Visual Studio 解决方案,使用 xunit 框架进行单元测试。
在此解决方案下,一个名为 - MainProject 和 MainProject_Test 的项目,
MainProject 是实现的“真实”源,MainProject_Test 用于单元测试,其中包含 xunit 属性、Assert 等。
我的问题是,每次我对 MainProject 进行更改时,我都会必须复制并粘贴到 MainProject_Test,这不是有效的方法。
那么人们如何反映代码但保留属性或断言呢?
另一个问题是,UnitTest项目有命名约定吗? MainProject_Test / MainProject.Test 还是 MainProjectTest?
I have a Visual Studio solution named - UnitTestProject, unit test with xunit framework.
Under this solution, a project named - MainProject and MainProject_Test,
The MainProject is the "Real" Source for implementation, the MainProject_Test for unittest, which contain the xunit attribute,Assert etc..
My question is, everytime i make change on MainProject, i have to copy&paste to MainProject_Test, it is not efficient way.
So how did the people reflect the code but retain the attribute or Assertion ?
Another question is, is it any name convention of UnitTest project? MainProject_Test / MainProject.Test or MainProjectTest?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该从单元测试项目中引用您的主项目。在解决方案资源管理器中右键单击测试项目的引用节点以添加引用。
我将测试项目命名为
MainProject.Test
。You should reference your main project from your unit test project. Right-click on the references node of the test project in solution explorer to add the reference.
I would name the test project
MainProject.Test
.MainProject_Test 应引用 MainProject。它不应该拥有所有代码的副本。
常见的命名约定是 MainProject 和 MainProject.Tests,但这样的约定有很多。
MainProject_Test should reference MainProject. It shouldn't have a copy of all its code.
A common naming convention is MainProject and MainProject.Tests, but there are a number of such conventions.