TDD - 在空项目中创建一个新类,以使添加的依赖项变得明确
使用 TDD,我正在考虑为我创建的每个新类创建一个(废弃的)空项目作为测试工具/容器。所以它存在于一个小小的私人泡沫中。
当我有依赖项并且需要从更广泛的项目中获取其他内容时,我必须做一些工作才能将其添加到我的干净项目文件中,并且我被迫考虑这种依赖项。假设我的班级有一个单一的责任,那么我不应该做太多这样的事情。
另一个好处是几乎即时的编译/测试/编辑周期。
一旦我对课程感到满意,我就可以将其添加到主项目/解决方案中。
以前有人做过类似的事情吗?或者这太疯狂了?
Using TDD, I'm considering creating an (throw-away) empty project as Test-harness/container for each new class I create. So that it exists in a little private bubble.
When I have a dependency and need to get something else from the wider project then I have to do some work to add it into my clean project file and I'm forced into thinking about this dependency. Assuming my class has a single responsibility then I ought not to have to do this very much.
Another benefit is an almost instant compile / test / edit cycle.
Once I'm happy with the class, I can then add it to the main project/solution.
Has anyone done anything similar before or is this crazy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我参加过使用 Endeavour 的演示。他们高度依赖的概念之一是解耦,正如您所建议的:
Endeavor 简而言之是一个强大的 VS 开发环境/插件,有助于归档这些东西。在许多其他内容中,它还挂钩/创建来自 SourceSafe 的夜间构建,以定义正在构建的 dll 并将其放置在共享文件夹中。
当您创建依赖于其他服务的代码时,您不会引用 VS 项目,而是引用共享文件夹中已编译的 DLL。
通过这样做,KLE 建议的一些缺点得到了解决:
中间立场:
但当然也有一个缺点:
我目前正在思考如何在不完全安装 Endeavor 的情况下实现此设置的好处,因为它是一个相当庞大的产品,真的很多(你们并不都需要)。
I have been to a presentation for using Endeavour. One of the concepts they depended highly upon was decoupling as you suggest:
Endeavour is in a nutshell a powerfull development environment / plugin for VS which helps archieving these things. Among a lot of other stuff it also hooks into / creates a nightly build from SourceSafe to define which dll's are building and places those in a shared folder.
When you create code which depends on an other service you don't reference the VS project but the compiled DLL in the shared folder.
By doing this a few of the drawbacks suggested by KLE are resolved:
Middle ground:
But ofcourse there is also a downside:
I am currently in the process of thinking how to archieve the benefits of this setup without the full-blown install of Endeavour because its a pretty massive product which does really much (which you won't all need).
我一般没有这样做,创建一个空项目来测试新类,尽管如果我不想修改编辑器中的当前项目,则可能会发生这种情况。
优点可能是:
缺点可能是:
import
语句找到。总的来说,恐怕这不会节省时间......:-(
I have not done this in general, create an empty project to test a new class, although it could happen if I don't want to modify the current projects in my editor.
The advantages could be :
The drawbacks could be :
import
statements.Overall, I'm afraid this would not be a timesaver... :-(