如何使用第三方dll单元测试.EXE? [英] How do you Unit Test an .EXE with 3rd party dll?

查看:107
本文介绍了如何使用第三方dll单元测试.EXE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍在学习TDD的黑暗艺术,最近

I'm still learning the dark arts of TDD and recently I've been trying to learn how to do TDD in VB6 and what I basically narrow down the list to was the free simplyvbunit and the most costly vbunit3.

我的应用程序是一个带有大量第三方dll的RTF编辑器,我在Google中搜寻高低档,以查找如何对该exe文件进行单元测试.

My application is an richtext editor with plenty of 3rd party dll and I was scouring high and low in Google to find how to do unit test this exe file.

所以我的问题是如何对exe文件进行单元测试?特别是在VB6的环境中,如果您有使用vbunit3或simplyvbunit的任何很好的示例,那么您就只是一个救命稻草,因为我现在正忙于编写材料,而我仍然无法编写一个单元测试:(

So my question is how do you unit test an exe file? Especially in the context for VB6 and if you have any good example with vbunit3 or simplyvbunit, you're simply a lifesaver as I'm drowing in the material right now and I still can't write one unit test yet :(

实际上,该应用程序由许多形式,模块和类模块组成,当我对其进行编译时,它当然会变成包装精美的.EXE文件.为了使事情变得更复杂,存在大量的全局变量.

Actually the app consists of many forms, modules and class modules and when I compile it, it of course becomes nice neatly packaged .EXE file. And to make things more complicated there are quite a number of global variables flying around.

但是我的主要目的是对代码的全部或大部分易碎部分进行单元测试.而且我想确保我可以将测试和代码分开.所以我认为最好的方法是通过添加引用等方式直接测试exe.

But my main intention is to unit test all or most breakable part of the code. And i want to ensure that i can keep the test and the code separate. So i thought that the best way to do is, is to somehow directly test the exe via add reference, etc.

有更好的方法吗?

推荐答案

单元测试和集成测试之间存在区别.您不对可执行文件进行单元测试.您可以对所用的小型独立计算单元(例如方法或过程)进行单元测试,具体取决于所使用的语言.集成测试将测试较大的组件,例如API,第三方组件,甚至可执行文件,以确保它们对于给定的一组输入(好或坏)能够按预期工作.虽然您可以使用单元测试工具对API或插件组件进行一些集成测试,但我认为您不会找到许多可用于测试可执行文件的单元测试工具.还有其他类型的测试工具可以在此方面做得更好.只需编写提供不同类型输入并检查其输出的脚本就可以满足许多情况.

There is a difference between unit tests and integration tests. You don't unit test an executable. You unit test small, self-contained units of computation, like a method or a procedure, depending on what language you are using. An integration test would test larger components, like APIs, third-party components, or even executables to make sure that they work as expected for a given set of inputs (good or bad). While you can do some integration testing of APIs or plug-in components with unit testing tools, I don't think you'll find many unit testing tools that work to test executables. There are other types of test tools that will do a better job at this. Simply writing scripts that provide different types of inputs and check their outputs may be sufficient for many scenarios.

如果您想了解有关TDD和单元测试的更多信息,则应将其应用于VB6中的功能或过程-尽管我建议使用VB.NET(或C#)并进行面向对象的开发.通常,这些工具是面向OO风格的编程的.

If you want to learn more about TDD and unit testing, you should apply it to functions or procedures in VB6 -- although, I'd recommend VB.NET (or C#) and doing object-oriented development. Typically the tools are oriented towards OO-style programming.

这篇关于如何使用第三方dll单元测试.EXE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆