Boost.Test : Project setting in Visual 2010

Hello,
I am trying to setup in Visual C++ 2010 some projects to use Boost.Test.
I have a project with some classes I want to test. This project builds a static library. I put in this project a test file ; here is its content :
#define BOOST_TEST_MODULE MyTest
#include

#define BOOST_TEST_MODULE MyTest #include
BOOST_AUTO_TEST_CASE(Test1) { BOOST_REQUIRE(false); }
I created an other project (a console program). Its content is :
#define BOOST_TEST_MAIN #include
Can you remove the #define BOOST_TEST_MODULE MeTest. You don't need that.
Just do:
#include

Hello,
Can you remove the #define BOOST_TEST_MODULE MeTest. You don't need that. Just do:
#include
BOOST_AUTO_TEST_CASE( small_test ) { // ... }
Same. Actually, I am doing this tutorial : http://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te... And at the end of the page 2, I get "test tree is empty" : the OneHasNoFactors is not seen.

[Please do not mail me a copy of your followup] boost-users@lists.boost.org spake the secret code <1522520332.33141712.1365147196271.JavaMail.root@zimbra59-e10.priv.proxad.net> thusly:
Actually, I am doing this tutorial :
http://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-te... http://legalizeadulthood.wordpress.com/2009/07/05/c-unit-tests-with-boost-te...
And at the end of the page 2, I get "test tree is empty" : the OneHasNoFactors is not seen.
If you look more closely at my tutorial, the static library contains the system under test. The unit tests are *not* in the library containing the system under test. In the section "First Failing Test: Going Red", I wrote: "Add a new source file to the Test project called TestPrimeFactors.cpp and enter this code:" You don't want to mix production code and test code into the same source files, or the same project. If you start to mix them together, it's too easy for production code to somehow start depending on test code, or production code having data in it that is only used for testing and so-on. If you keep the production code and test code separate, then it is harder for test code to accidentally sneak into production code. In these tutorials, I do this by keeping all the unit tests in the project that builds the test executable and all the production code in a static library that is a link input to the test executable. -- "The Direct3D Graphics Pipeline" free book http://tinyurl.com/d3d-pipeline The Computer Graphics Museum http://computergraphicsmuseum.org The Terminals Wiki http://terminals.classiccmp.org Legalize Adulthood! (my blog) http://legalizeadulthood.wordpress.com

Thanks a lot for your message, Richard. Following the messages from other people in this thread, I was resolved to do what you/say, by being convinced that your tutorial, as I have understood it, was supposed to work on Visual 2008, but that Visual 2010 introduced a bug. Thanks a lot for the clarification. It seems I didn't read you tutorial with enough care. ----- Mail original -----
De: "Richard"
À: boost-users@lists.boost.org Envoyé: Vendredi 5 Avril 2013 20:36:47 Objet: Re: [Boost-users] Boost.Test : Project setting in Visual 2010 [Please do not mail me a copy of your followup]
boost-users@lists.boost.org spake the secret code
If you look more closely at my tutorial, the static library contains the system under test.
The unit tests are *not* in the library containing the system under test.
In the section "First Failing Test: Going Red", I wrote:
"Add a new source file to the Test project called TestPrimeFactors.cpp and enter this code:"
You don't want to mix production code and test code into the same source files, or the same project. If you start to mix them together, it's too easy for production code to somehow start depending on test code, or production code having data in it that is only used for testing and so-on.
If you keep the production code and test code separate, then it is harder for test code to accidentally sneak into production code.
In these tutorials, I do this by keeping all the unit tests in the project that builds the test executable and all the production code in a static library that is a link input to the test executable.

[Please do not mail me a copy of your followup] boost-users@lists.boost.org spake the secret code <54950449.38289616.1365282268639.JavaMail.root@zimbra59-e10.priv.proxad.net> thusly:
Following the messages from other people in this thread, I was resolved to do what you/say, by being convinced that your tutorial, as I have understood it, was supposed to work on Visual 2008, but that Visual 2010 introduced a bug. Thanks a lot for the clarification.
Yeah, there shouldn't be any problem using that with either VS 2010 or VS 2012. I've done lots of Boost.Test unit testing in both these environments following the technique outlined there. I did some minor edits to the tutorial based on your experience to try and make things clearer. I was also thinking that maybe a video of the process might make things more clearer. Not everyone learns the same way and having multiple ways to learn things reaches more people. -- "The Direct3D Graphics Pipeline" free book http://tinyurl.com/d3d-pipeline The Computer Graphics Museum http://computergraphicsmuseum.org The Terminals Wiki http://terminals.classiccmp.org Legalize Adulthood! (my blog) http://legalizeadulthood.wordpress.com

Hello,
I did some minor edits to the tutorial based on your experience to try and make things clearer.
If I have a suggestion, you should use more text formating functions when describing processes (bullet points, bold characters...). Ie, on the second page : Finally, we need to adjust the include search order in the test project so that it can see the headers in the production code. In the Solution Explorer window, select Properties from the context menu on the Test project. Select All Configurations in the Configurations combobox in the upper left. Then select the Configuration Properties / C/C++ / General item in the treeview. On the right enter “$(SolutionDir)/PrimeFactors” into the Additional Include Directories property. Click OK. I would do : Finally, we need to adjust the include search order in the test project so that it can see the headers in the production code : * Go in the <b>Solution Explorer</b> window * Select <b>Properties/<b> from the context menu on the Test project * Select <b>All Configurations</b> in the Configurations combobox in the upper left * Select the <b>Configuration Properties / C/C++ / General</b> item in the treeview. * On the right enter <b>“$(SolutionDir)/PrimeFactors”</b> into the <b>Additional Include Directories</b> property. * Click OK. Anyway, your tutorial is aleady VERY useful as it is.
I was also thinking that maybe a video of the process might make things more clearer. Not everyone learns the same way and having multiple ways to learn things reaches more people.
Be careful with videos : don't rely too much on vocal input. You must speak clearly, not too fast, and reduce any accent because of non speaking english people. For these ones, texts are usually easier. But extra videos are always welcome.

[Please do not mail me a copy of your followup] boost-users@lists.boost.org spake the secret code <361749350.41975129.1365410384300.JavaMail.root@zimbra59-e10.priv.proxad.net> thusly:
I did some minor edits to the tutorial based on your experience to try and make things clearer.
If I have a suggestion, you should use more text formating functions when describing processes (bullet points, bold characters...).
That's a good suggestion -- make the recipe steps more explicit instead of prose. -- "The Direct3D Graphics Pipeline" free book http://tinyurl.com/d3d-pipeline The Computer Graphics Museum http://computergraphicsmuseum.org The Terminals Wiki http://terminals.classiccmp.org Legalize Adulthood! (my blog) http://legalizeadulthood.wordpress.com

Same.
Here is what I do. Please stick to the script as closely as possible. I
assume you use Visual Studio 2010.
1. Create an empty console project. Turn off precompiled headers.
2. Include boost path to compiler settings
3. Create main.cpp and include the following code:
#define BOOST_TEST_MAIN
#include

Here is what I do. Please stick to the script as closely as possible. I assume you use Visual Studio 2010.
1. Create an empty console project. Turn off precompiled headers. 2. Include boost path to compiler settings 3. Create main.cpp and include the following code:
#define BOOST_TEST_MAIN #include
3. Create test1.cpp and insert following code:
#include
BOOST_AUTO_TEST_CASE( test_1 ) { }
4. Add boost lib path to linker settings. 5. Compile.
Do you still have any problems?
No. I have problems only when the test is in a library (static), in an other project.

Please note that there is a similar question on StackOverflow : http://stackoverflow.com/questions/4877990/boost-test-tests-on-a-static-libr...

AMDG On 04/04/2013 01:55 AM, Oodini wrote:
I am trying to setup in Visual C++ 2010 some projects to use Boost.Test.
I have a project with some classes I want to test. This project builds a static library. I put in this project a test file ; here is its content :
<snip>
I created an other project (a console program). Its content is :
<snip>
When I execute this program, I get the message "test tree is empty".
Don't put your test cases in a static library. The linker will strip them. In Christ, Steven Watanabe
participants (5)
-
Christian Henning
-
legalize+jeeves@mail.xmission.com
-
Oodini
-
Oodini
-
Steven Watanabe