mirror of
https://github.com/boostorg/test.git
synced 2026-01-27 07:22:11 +00:00
139 lines
8.7 KiB
HTML
Executable File
139 lines
8.7 KiB
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>The Unit Test Framework compilation</TITLE>
|
|
<LINK rel="stylesheet" type="text/css" href="../../style/btl.css" media="screen">
|
|
<LINK rel="stylesheet" type="text/css" href="../../style/btl-print.css" media="print">
|
|
<META http-equiv="Content-Language" content="en-us">
|
|
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
</HEAD>
|
|
<BODY>
|
|
<DIV class="header"> <A href="../../index.html">Boost.Test</A> > <A href="../index.html">Components</A> > <A href="index.html">The
|
|
Test Framework</A> > <SPAN class="current_article">Compilation</SPAN> </DIV>
|
|
<DIV class="body"> <IMG src="../../btl1.gif" width="252" height="43" alt="Boost Test logo">
|
|
<H1 class="subtitle">The Unit Test Framework compilation instructions </H1>
|
|
<P class="first-line-indented">Unlike most boost libraries the Unit Test Framework
|
|
compilation may require you to go one extra mile. There are several alternative
|
|
options that you could consider:</P>
|
|
<UL>
|
|
<LI><A href="#static_build">Build standalone static library</A> (with possibility
|
|
to use <A href="#autolinking">auto linking feature</A>)</LI>
|
|
<LI><A href="#static_build">Build standalone dynamic library</A> (with possibility
|
|
to use <A href="#autolinking">auto linking feature</A>)</LI>
|
|
<LI><A href="#included_header">Single header that includes all the implementation
|
|
files</A></LI>
|
|
<LI><A href="#include_sources">Include the framework sources directly into
|
|
your test module project</A></LI>
|
|
</UL>
|
|
<P class="first-line-indented">Each option has it's advantages and drawbacks.
|
|
By default it's recommended to use standalone static library.</P>
|
|
<H4>Building standalone library<A name="build_standalone"></A></H4>
|
|
<P class="first-line-indented">The Unit Test Framework is comparatively complicated
|
|
library and implemented in close to hundred header and source files.
|
|
While there exist an alternative option to include the whole implementation
|
|
directly into your test module, for the long term usage the preferable solution
|
|
is to build the framework once and reuse it by linking to prebuild library.
|
|
Depending on your hardware this may save you significant time during compilation
|
|
and doesn't really require that much effort. </P>
|
|
<P class="first-line-indented">If you decided to go with standalone
|
|
library, you first need to build one. There are a varity of make systems
|
|
that allow you to do that. To name a few: GNU make and
|
|
similar, all kinds of integrated development environments. Boost preferred
|
|
solution is Boost.Build system, that is built on top of bjam tool. All make
|
|
systems require some kind of configuration file that list all files that
|
|
constitute the library and all the build options. For example makefile that
|
|
is used by make, Microsoft Visual Studio project file, Jamfile that is used
|
|
by Boost.Build. For the sake of simplicity lets call this file the makefile.
|
|
To build a stanalone library following files, that are located in the Boost
|
|
Test Library source directory, needs to be listed as source files in your
|
|
makefile:</P>
|
|
<P class="indented"> <A href="../../../src/compiler_log_formatter.cpp">compiler_log_formatter.cpp</A><BR>
|
|
<A href="../../../src/exception_safety.cpp">exception_safety.cpp</A><BR>
|
|
<A href="../../../src/execution_monitor.cpp">execution_monitor.cpp</A><BR>
|
|
<A href="../../../src/framework.cpp">framework.cpp</A><BR>
|
|
<A href="../../../src/interaction_based.cpp">interaction_based.cpp</A><BR>
|
|
<A href="../../../src/logged_expectations.cpp">logged_expectations.cpp</A><BR>
|
|
<A href="../../../src/plain_report_formatter.cpp">plain_report_formatter.cpp</A><BR>
|
|
<A href="../../../src/progress_monitor.cpp">progress_monitor.cpp</A><BR>
|
|
<A href="../../../src/results_collector.cpp">results_collector.cpp</A><BR>
|
|
<A href="../../../src/results_reporter.cpp">results_reporter.cpp</A><BR>
|
|
<A href="../../../src/unit_test_log.cpp">unit_test_log.cpp</A><BR>
|
|
<A href="../../../src/unit_test_main.cpp">unit_test_main.cpp</A><BR>
|
|
<A href="../../../src/unit_test_monitor.cpp">unit_test_monitor.cpp</A><BR>
|
|
<A href="../../../src/unit_test_parameters.cpp">unit_test_parameters.cpp</A><BR>
|
|
<A href="../../../src/unit_test_suite.cpp">unit_test_suite.cpp</A><BR>
|
|
<A href="../../../src/xml_log_formatter.cpp">xml_log_formatter.cpp</A><BR>
|
|
<A href="../../../src/xml_report_formatter.cpp">xml_report_formatter.cpp</A></P>
|
|
<P class="first-line-indented">The <A href="../../../build/Jamfile">Jamfile</A> for
|
|
use with Boost.Build system is supplied in libs/test/build directory. </P>
|
|
<H5>Building static library<A name="static_build"></A></H5>
|
|
<P class="first-line-indented">There are no additional build defines or options
|
|
required to build static library. Using
|
|
Boost.build system you could build the static library with a following command
|
|
from libs/test/build directory:</P>
|
|
<P class="indented">bjam -sTOOLS=<your-tool-name> "-sBUILD="boost_unit_test_framework</P>
|
|
<P class="first-line-indented">Also on windows you could use this Microsoft
|
|
Visual Studio .NET <A href="../../../build/msvc71_proj/unit_test_framework.vcproj">project
|
|
file.</A></P>
|
|
<H5>Building dynamic library<A name="shared_build"></A></H5>
|
|
<P class="first-line-indented">To build dynamic library you need to add BOOST_TEST_DYN_LINK
|
|
to the list of defines in makefile. Using
|
|
Boost.Build system you could build the dynamic library with a following
|
|
command from libs/test/build directory:</P>
|
|
<P class="indented">bjam -sTOOLS=<your-tool-name> "-sBUILD=" boost_unit_test_framework</P>
|
|
<P class="first-line-indented">Also on windows you could use this Microsoft
|
|
Visual Studio .NET <A href="../../../build/msvc71_proj/unit_test_framework_dll.vcproj">project
|
|
file.</A> </P>
|
|
<P class="first-line-indented">Note that the same flag BOOST_TEST_DYN_LINK
|
|
needs to be defined during test module compilation for it to successfully
|
|
link with dynamic library.
|
|
</P>
|
|
<H5>Using autolinking feature<A name="autolinking"></A></H5>
|
|
<P class="first-line-indented">For the Microsoft family of compilers Boost Test provides an ability to
|
|
automatically select proper library name and add it to the list of objects
|
|
to be linked with. By default this feature is on. To disable this feature
|
|
you should define the flag BOOST_TEST_NO_LIB. More detailes on autolinking
|
|
feature implementation and configuration you could see <A href="../../../../../more/separate_compilation.html#auto-link">here</A>.</P>
|
|
<H4>Using "included" option<A name="included_header"></A></H4>
|
|
<P class="first-line-indented">While building standalone library is preferred
|
|
solution, some users prefer "quick and dirty" include one. The Unit Test
|
|
Framework provides an ability to do that. The only change that is required
|
|
for you to employ it is the path to the header file you include. So the usual
|
|
include staments:</P>
|
|
<PRE class="code">#<SPAN class="reserv-word">define</SPAN> BOOST_TEST_MAIN ...
|
|
#<SPAN class="reserv-word">include</SPAN> <boost/test/unit_test.hpp>
|
|
|
|
<SPAN class="comment">...</SPAN></PRE>
|
|
<P>becomes:</P>
|
|
<PRE class="code">#<SPAN class="reserv-word">define</SPAN> BOOST_TEST_MAIN ...
|
|
#<SPAN class="reserv-word">include</SPAN> <boost/test/included/unit_test.hpp>
|
|
|
|
...</PRE>
|
|
|
|
<P class="first-line-indented">This way you don't need to link with any prebuild
|
|
library. The whole Unit Test Framework implementation in included directly
|
|
into your file. The autolionking feature is disabled also. </P>
|
|
|
|
<H4>Including sources directly into test module project<A name="include_sources"></A> </H4>
|
|
<P class="first-line-indented">Finally you could include all the files listed
|
|
in <A href="#build_standalone">build standalone library</A> section directly
|
|
into you test module makefile. Obviosly there is no sence to employ an options
|
|
for dynamic build since you you are linking with implementation statically. </P>
|
|
</DIV>
|
|
|
|
<DIV class="footer">
|
|
<DIV class="footer-body">
|
|
<P> © <A name="Copyright">Copyright</A> <A href="mailto:boost-test%20at%20emailaccount%20dot%20com%20%28please%20unobscure%29">Gennadiy
|
|
Rozental</A> 2001-2006. <BR>
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
file <A href="../../../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A> or copy
|
|
at <A href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</A>)</P>
|
|
<P>Revised:
|
|
<!-- #BeginDate format:Sw1 -->28 February, 2006<!-- #EndDate -->
|
|
</P>
|
|
</DIV>
|
|
</DIV>
|
|
</BODY>
|
|
</HTML>
|
|
<!-- #BeginDate format:Sw1 -->28 February, 2006<!-- #EndDate -->
|