How are you Unit Test.EXE with a third-party dll?

I am still studying the dark arts of TDD and lately I have been trying to find out how to make TDD in VB6 and what I mainly judge on the list is it was free rustic and the most expensive vbunit3.

My application is a richtext editor with a lot of third-party DLLs, and I quickly searched on Google to find how to do unit test this exe file.

So my question is: how do you unit test exe file? Especially in the context of VB6, and if you have a good example with vbunit3 or simplevbunit, you are just a lifesaver since I am napping in the material now and I still cannot write another unit test :(

Edit

In fact, the application consists of many forms, modules, and class modules, and when I compile it, of course, it becomes a beautiful, neatly packaged .EXE file. And to complicate the situation, there are a number of global variables around.

But my main intention is to unit test all or the most discontinuous part of the code. And I want me to be able to save the test and code separately. So I thought that the best way to do this is to somehow directly test exe through the add link, etc.

Is there a better way to do this?

+6
unit-testing tdd vb6 simplyvbunit
source share
6 answers

There is a difference between unit tests and integration tests. You are not running the unit test executable. You unit test small, self-contained units of calculation, such as a method or procedure, depending on which language you use. The integration test will test larger components, such as APIs, third-party components, or even executables to ensure that they work as expected for a given set of inputs (good or bad). Although you can perform integration testing of APIs or plug-ins with unit testing tools, I don’t think you will find many unit testing tools that work to check executable files. There are other types of test tools to help you with this. Just writing scripts that provide different types of inputs and checking 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 would recommend VB.NET (or C #) and do object-oriented development. Typically, tools are oriented towards OO-style programming.

+6
source share

ActiveB controls in VB are great timekeepers, but they are the scourge of effective test-based development.

To effectively test the entire VB6 application, ideally you need to have a design in which the EXE is a thin shell on top of the ActiveX DLL that does all the work. Forms implement the interface and register in the DLL. Therefore, if you have an order entry form, it implements the IOrderEntryForm interface, and events will call methods in the OrderEntry class located in the MyAppUI dialog box.

To emphasize in Visual Basic 6, FORMS can implement an interface. The form is then registered with the user interface class in this LOAD event. Form events (such as MyButton_Click) invoke methods in the user interface class. A user interface class using form interface methods to change what is displayed. This is additional work, but it saves a lot of time for testing. Also maintenance, as you can change what the form looks like once the implemented interface remains the same.

It also means that before you have something like MYEXE-> MyActiveXDLL, you will turn into MYEXE-> MyUIDLL-> MyActiveXDLL.

For your test environment, you create an ActiveX DLL that mocks the user interface by creating classes that implement various forms of interface. The UI DLL knows no difference, and you have full control over which inputs are sent and what you are reading.

Please note that this type of design pattern is discussed here . I used it as the basis for developing and supporting my company's CAD / CAM application for metal cutting machines.

Third-party ActiveX controls are a bug in this scheme. This is because the heavy lifting code is inside the control itself. The more complex the ActiveX control, the worse the problem. The trend in my company is to reduce our dependence on third-party controls for internal applications.

However, like any algorithm and design pattern, this involves a challenge. How many problems you get in the area of ​​your software using advanced text control. If not so much, you can leave with the test script both manual and automatic (i.e., sending strokes to the application) and use unit test for the rest.

A critical element of using Unit Testing of your FULL application is overlaying as much as possible on the interfaces. Just do what you can at the moment, and pay attention to those areas that you want to change when you develop in the future. Do not despair if you do not have 100% coverage right away or even the next year.

+4
source share

Another use case is to make an ActiveX EXE application. Your unit test application may refer to your application as an ActiveX DLL. You will need to do a lot of research to make it work properly, since I worked with VB6, and I'm sure there were a few tricks to make it work.

+1
source share

The only good piece of advice I could give is to pick up Michael Faires to work efficiently with legacy code . I think your biggest problem will be your toolbox, as I know that the tools for testing VB6 modules are not so strong.

You can also try asking TDD Yahoo! List , as I know, at least a couple people use vbunit3 there.

0
source share

Of course, you can unit test a separate EXE. See how many applications consist of several EXEs.

For third-party components, how do you decide to test with standard VB6 components? Other MS components? Same thing with a third-party component.

0
source share

And to do more complex things, there are quite a few global variables flying around.

The first refactoring is the transfer of global variables to a class in an ActiveX DLL. The instancing property of this class must be set to GLOBAL MULTIUSE. When an EXE refers to ActiveX, the variables will still be global, however when you rip out the EXE to replace it with a test harness, the harness can access the global variables.

Once your tests pass, you can continue to refactor to reduce the number of global variables.

0
source share

All Articles