Results 1 to 5 of 5

Thread: How to install and use Cppunit

  1. #1
    Join Date
    Feb 2010
    Posts
    796

    How to install and use Cppunit

    Hi all,

    I want to use open-source unit testing tool. I found that the very popular tool CppUnit which contains a number of classes, contribute to white-box testing and regression test suite to create your own. I want to know that some of the more useful CppUnit features, such as TestCase, TestSuite, TestFixture, TestRunner and supporting macros. Please help. Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    How to install and use Cppunit

    you need to run and configure Command, and then run the make install. Note that for cygwin and other platforms, this process may not be successfully completed, it must pass INSTALL. If the installation is successful, should be the installation path (CPPUNIT_HOME). To see CppUnit the include and lib folders.
    CppUnit installation directory structure are looks as
    Code:
    [arpan @ tintin] echo $ CPPUNIT_HOME
    / home / arpan / ibm / cppUnit
    [arpan @ tintin] ls $ CPPUNIT_HOME
    To compile use the CppUnit test, we must build the source code:
    Code:
    g + + <C/C++ file>-I $ CPPUNIT_HOME / include-L $ CPPUNIT_HOME / lib-lcppunit
    Note that if you are using a shared library version of CppUnit, you may need to use -Ldl Option to compile the source code. After the installation, may need to modify the UNIX environment variable LD_LIBRARY_PATH to reflect libcppunit.

  3. #3
    Join Date
    Nov 2005
    Posts
    1,323

    How to install and use Cppunit

    You need to create a basic test using the CppUnit. CppUnit with a set of pre-defined classes, you can easily use them to design tests. In order to maintain continuity, first take a look in this code:
    Code:
    # ifndef _MYSTRING
    # define _MYSTRING
    class mystring (
      char * buffer;
      int length;
      public:
        void setbuffer (char * s) (buffer = s; length = strlen (s);)
        char & operator [] (const int index) (return buffer [index];)
        int size () (return length;)
     );
    # endif
    The string associated with the typical inspection include checking whether the empty string the length of the 0 and interviews that go beyond the index is causing the error message / exception. Check and reply.

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    How to install and use Cppunit

    Check th ebelow code:
    Code:
    # include <cppunit/TestCase.h>
    # include <cppunit/ui/text/TextTestRunner.h>
    class mystringTest: public CppUnit:: TestCase (
    public:
      void runTest () (
        mystring s;
        CPPUNIT_ASSERT_MESSAGE ( "String Length Non-Zero", s.size ()! = 0);
      )
    );
    int main ()
    (
      mystringTest test;
      CppUnit:: TextTestRunner runner;
      runner.addTest (& test);
      runner.run ();
      return 0;
    )
    To create a unit test for the string class, you need to create CppUnit:: TestCase Class, subclass, and override runTest Method. Defines the test itself, the instantiation TextTestRunner Class, this is a controller class, you must add the test (vide addTest Methods). Check and reply.

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    How to install and use Cppunit

    Developers will continue to add features, these features also need to be tested. In the same test suite in the continuous addition of tests will gradually lead to confusion, but also easy as the first test of the revised amendment increasing the loss. Fortunately, CppUnit provides a useful CPPUNIT_TEST_SUB_SUITE Macro, you can use it to expand the existing test suite.Listing 13 Use this macro. Note that the new class mystringTestNew from the front myStringTest Derived class. CPPUNIT_TEST_SUB_SUITE Macro two parameters is the new class and its superclass. On the client, only to register this new class, two classes do not need to register. Other parts of grammar and syntax to create the same test suite. All the best.

Similar Threads

  1. Vista Home Premium Install Hangs At Completing. (Clean Install)
    By Serges2K in forum Vista Setup and Install
    Replies: 3
    Last Post: 30-10-2011, 06:54 PM
  2. Replies: 11
    Last Post: 14-09-2011, 10:42 PM
  3. Cannot install Dell Latitude E6400 Webcam after clean install
    By The-Apollo in forum Operating Systems
    Replies: 6
    Last Post: 10-09-2010, 02:30 AM
  4. Cant Install Zone Alarm - Install Error 1636
    By Tomthegreat in forum Networking & Security
    Replies: 3
    Last Post: 25-08-2009, 10:09 PM
  5. WSUS Install Failure on Win2k3 Std. (PSFSIP failed to install)
    By Deabelos in forum Server Update Service
    Replies: 3
    Last Post: 01-09-2007, 03:20 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,861,832.87547 seconds with 16 queries