I'm working on a C++ project in Visual Studio and wanted to test it using Google Test.
In order to do so, I built a solution which includes three projects:
I wrote the code in the code project and a test in the test project.
When I tried building the solution, I got a lnk2019 error which stopped happening when I moved the classes to the tests project (but that's not where I want them to be).
I read that the best way to do so is by writing the classes as a library so I'll be able to use them in both (code and tests) projects.
Should I do that as a static library or as a DLL (and why)?
Other solutions are welcomed as well.
The key thing to understand here: you are getting things backwards.
You do not make this decision in order to get to "easier" testing. You first and foremost have to understand the "production requirements" towards your delivery. You create a static library, if that is the best for shipping your product. If not, you create a dynamic library.
For testing, you either deal with the chosen "delivery format"; or you think about a simple way that allows you to build a different thing for testing (although that is discouraged, as you want to test your product, nothing else).
Don't get me wrong: it is important to design for testing; but the decision you are asking for should be driven by your production requirements!
In other words: the "form factor" of your product should depend on product requirements, it should not be determined by your test setup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With