Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 68c0c2ff89d8bf9051ff1b9773ed48e4 > files > 3296

libzypp-doc-17.9.0-1.1.mga7.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libzypp: Writing and tunning testcases</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libzypp
   &#160;<span id="projectnumber">17.9.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('Testcases.html','');});
/* @license-end */
</script>
<div id="doc-content">
<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">Writing and tunning testcases </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="Introduction"></a>
Introduction</h1>
<p>ZYpp has a suite of tests located in under test/ directory of the source tree.</p>
<p>Right now, tests are grouped into</p>
<ul>
<li>media : tests related to downloading and the http/ftp/nfs/iso abstraction layer</li>
<li>parser : tests related to classes that offer file format parsing</li>
<li>repo : tests related to repository handling</li>
<li>sat : tests related to the sat-solver integration</li>
<li>zypp : tests related to the main libzypp classes and APIs</li>
</ul>
<p>Tests are written using boost test library.</p>
<ul>
<li><a href="http://www.boost.org/doc/libs/1_36_0/libs/test/doc/html/index.html">Boost Test Library</a></li>
<li><a href="http://www.boost.org/doc/libs/1_36_0/libs/test/doc/html/utf.html">The Unit Test Framework</a></li>
<li><a href="http://www.boost.org/doc/libs/1_36_0/libs/test/doc/html/utf/testing-tools/reference.html">The UTF testing tools reference</a></li>
</ul>
<h1><a class="anchor" id="Anatomy"></a>
Anatomy of a ZYpp testcase</h1>
<p>The file should be in one of the described groups, and by general rule it is named ClassName_test.cc where ClassName is the name of the class or module the test covers.</p>
<p>Data and fixtures are stored in data/ directories in each test group. However groups may use and reference data from other test groups. The macro TESTS_SRC_DIR is defined as the tests/ directory located in libzypp source directory. You can build the paths to the data/fixtures using that macro.</p>
<p>A simple testcase:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="Date_8h.html">zypp/Date.h</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &lt;boost/test/auto_unit_test.hpp&gt;</span></div><div class="line"></div><div class="line">BOOST_AUTO_TEST_CASE(date_test)</div><div class="line">{</div><div class="line">  std::string format = <span class="stringliteral">&quot;%Y-%m-%d %H:%M:%S&quot;</span>;</div><div class="line">  std::string date = <span class="stringliteral">&quot;2009-02-14 00:31:30&quot;</span>;</div><div class="line">  BOOST_CHECK_EQUAL(<a class="code" href="classzypp_1_1Date.html">zypp::Date</a>(date,format).<a class="code" href="group__ZYPP__SMART__PTR.html#ga9ffc8a01367e8a71d551ea8dbdc356f2">form</a>(format), date);</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="Building"></a>
Building and running the testsuite</h1>
<ul>
<li>Build the testsuite</li>
</ul>
<pre class="fragment">$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/prefix ..
$ cd tests
$ make
</pre><ul>
<li>Run a simple test</li>
</ul>
<pre class="fragment">$ zypp/Date_test
Running 1 test case...

*** No errors detected
</pre><ul>
<li>Run all tests</li>
</ul>
<pre class="fragment">$ ctest .
</pre><h1><a class="anchor" id="Building"></a>
Building and running the testsuite</h1>
<pre class="fragment">  - added tests/data/openSUSE-11.1 containing raw susetags metadata.
  Keeping .solv files in svn is somewhat inconvenient, as you must rebuild them
  if something in libsolv changes.
</pre><pre class="fragment">  - added  tests/include as location for includes that might be used in multiple
  testcases.
</pre><pre class="fragment">  - added tests/include/TestSetup.h to ease building a test environment below
  some tempdir. Currently supports easy setup of Target, RepoManager and
  loading data (raw metadata and .solv files) into the pool.

  That's how it currently looks like:

          #include "TestSetup.h"

          BOOST_AUTO_TEST_CASE(WhatProvides)
          {
            TestSetup test( Arch_x86_64 );  // use x86_64 as system arch
            test.loadTarget(); // initialize and load target
            test.loadRepo( TESTS_SRC_DIR"/data/openSUSE-11.1" );

  This is all you need to setup Target, RepoManager below some temp directory
  and load the raw metadata into the pool.

  In case you want to setup the system below some fix directory, use:

          TestSetup test( "/tmp/mydir", Arch_x86_64 );

  You directory is used as it is and not removed at the end.
</pre><pre class="fragment">  - Added support for loading helix files e.g. from testcases. This is what
    you need to load all repos from a solver testcase into the pool:

        #include "TestSetup.h"

        BOOST_AUTO_TEST_CASE(test)
        {
                TestSetup test( Arch_x86_64 );
                test.loadTestcaseRepos( "/suse/ma/BUGS/153548/YaST2/solverTestcase" );</pre><h1><a class="anchor" id="References"></a>
References</h1>
</div></div><!-- PageDoc -->
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
  </ul>
</div>
</body>
</html>