Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you Unit Test an .EXE with 3rd party dll?

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.

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.

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 :(

Edit

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.

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.

Is there a better way to do this?

like image 816
melaos Avatar asked Feb 03 '09 03:02

melaos


People also ask

How do I test a DLL file?

Type "sfc /scannow" at the command prompt, then press the "Enter" key. The System File Checker will run. It will check for all missing and corrupted DLL files and replace them.

How do I run a CPP unit test in Visual Studio?

Right-click your solution and choose Add > New > Project. Click the Visual C++ category, and choose the Test sub-category. Select Native Unit Test Project, give the project a descriptive name, and then click OK.

How do I run a unit test file?

To run all the tests in a default group, choose the Run icon and then choose the group on the menu. Select the individual tests that you want to run, open the right-click menu for a selected test and then choose Run Selected Tests (or press Ctrl + R, T).

What is unit test file?

Unit tests are typically automated tests written and run by software developers to ensure that a section of an application (known as the "unit") meets its design and behaves as intended. In procedural programming, a unit could be an entire module, but it is more commonly an individual function or procedure.


1 Answers

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.

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.

like image 65
tvanfosson Avatar answered Nov 04 '22 20:11

tvanfosson