tags:

views:

42

answers:

2

Hi everyone,

I have a new native C++ class that I want to test. It is exported from a dll (project consists of 1 exe and a lot of dll)

What's better: to test it through static linking or through dynamic linking? What do you usually do in your projects?

The problem is that in the project that I am working on it will take a lot of time to make it compile statically. So I want to know does testing worth a lot of refactoring.

Thanks in advance

A: 

In my projects I like to test directly the DLL, so I have the access to the exported functions and classes exactly in the same way as the will work in the real application (there may be some subtle differences with static linking).

martjno
And what if the class is also used in that dll?
direct4d
It's testable anyway, of course, not as if it was used internally
martjno
A: 

At work, we try to run two sets of tests.

First, we link statically for unit tests of each function, whether it's an exported function or not. This lets us test each function in a more controlled environment by eliminating any problems we find in the "back end" code.

Next, we link dynamically to test the exported functions. This lets us test the exported functions knowing that everything works further down the call stack and into the non-exported functions in the library.

This method has worked well for us, as we have found bugs in the statically-linked tests that we fixed before finding different bugs when running the dynamically-linked tests. Had we only tested using dynamic linking, we would have spent more time debugging/fixing a compound problem than we actually spent fixing two individual, isolated problems.

psublue