被测试的代码应该编译为 DLL 还是可执行文件?

发布于 2024-08-29 01:29:38 字数 363 浏览 3 评论 0原文

我有两个项目的解决方案。一个用于生产代码的项目,另一个用于单元测试的项目。我是按照我从 SO 那里得到的建议这样做的。

我注意到在调试文件夹中它包含可执行形式的生产代码。我在删除可执行文件后使用 NUnit 运行测试,但它们在尝试查找可执行文件时都失败了。所以它肯定是在努力寻找它。然后我快速阅读了一下,找出 DLL 和可执行文件哪个更好。 DLL 似乎要快得多,因为它们共享内存空间,而可执行文件之间的通信速度较慢。

不幸的是,我们的生产代码需要是可执行的。所以单元测试会稍微慢一些。我对此不太担心。但该项目确实依赖于另一个库中编写的代码,该库目前也是可执行格式的。

是否应该将公开某种 SDK 的项目编译为 DLL,然后将使用 SDK 的项目编译为可执行文件?

I have a solution with two projects. One for project for the production code and another project for the unit tests. I did this as per the suggestions I got here from SO.

I noticed that in the Debug Folder that it includes the production code in executable form. I used NUnit to run the tests after removing the executable and they all fail trying to find the executable. So it definitely is trying to find it. I then did a quick read to find out which is better, a DLL or an executable. It seems that an DLL is much faster as they share memory space where communication between executables is slower.

Unforunately our production code needs to be an exectuable. So the unit tests will be slightly slower. I am not too worried about that. But the project does rely on code written in another library which is also in executable format at the moment.

Should the projects that expose some sort of SDK rather be compiled to an DLL and then the projects that use the SDK be compiled to executable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑叹一世浮沉 2024-09-05 01:29:38

仅仅因为它是一个可执行文件并不意味着它会作为单独的进程加载。

在 .NET 中,您可以像加载 DLL 一样轻松地将 EXE 文件作为程序集加载。这就是这种情况下发生的情况(无论如何,我想)——没有跨进程通信,没有问题。

如果您真正测试的东西在逻辑上应该是可执行文件,那么就可以了。

Just because it's an executable file doesn't mean it's being loaded as a separate process.

In .NET you can load an EXE file as an assembly just as easily as a DLL. That's what's happening in this case (I'd imagine, anyway) - no cross-process communication, no problem.

If you're genuinely testing something which should logically be an executable, then that's fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文